ACC SHELL

Path : /srv/www/vhosts/alfa-com/modules/
File Upload :
Current File : /srv/www/vhosts/alfa-com/modules/pages.php

<?php
	class o_pages extends object
	{
		public function initialize($phase)
		{
			parent::initialize($phase);
			
			if ($phase == 0)
			{
				$this->set('tree', true);
				$this->set('group-filter', Feq('group', true));
				$this->set('order', array('+group', '+priority', '+title'));
				$this->f('otitle')->get = 'return ($object->id ? $object->title : "");';
	
				$f = $this->definePid();
				$f = $this->defineIdAutoIncrement();
				$f = $this->defineOCreated();
				$f = $this->defineOModified();
				
				$f = $this->defineGroup();
				$f = $this->definePriority();

				$f = $this->defineStringLocalized('meta_url');
				$f = $this->defineStringLocalized('meta_title');
				$f = $this->defineStringLocalized('meta_keywords');
				$f = $this->defineStringLocalized('meta_description');
				
				$f = $this->defineStringLocalized('title');
				$f = $this->defineTextLocalized('summary');
				$f = $this->defineTextLocalizedHTML('text');
				$f = $this->defineImages();
				$f = $this->defineAttachments();
	
				$f = $this->defineV('url', Field::TYPE_STRING);
				$f->get = 'return (!$object->id ? "" : (($object->meta_url ? strtolower($object->meta_url) : U::urlize($object->title)) . "-" . $object->id));';
			}
		}
	}

	class pages extends ObjectModule
	{
		public function initialize($phase)
		{
			parent::initialize($phase);

			if ($phase == 4)
			{
				$this->action('list')->set('order-fields', array('group', 'priority', 'title'));
				$this->action('list')->set('columns', array('group', 'priority', 'title', 'omodified'));
				$this->action('list')->set('actions', array('new', 'edit', 'delete'));

				$this->action('get')->set('object-fields', array('id'));
			}
		}
		
		public function prepare($invocation, $action, $phase, $result)
		{
			$result = parent::prepare($invocation, $action, $phase, $result);
			
			/*if (($action->id == 'edit') || ($action->id == 'delete'))
			{
				$object = $invocation->get('object');
				if ($object)
				{
					$protected = $this->get('protected-pages', array());
					foreach ($protected as $id)
						if (($object->id == $id) || ($object->oid == $id))
							$result = false;
				}
			}*/
			
			return $result;
		}

		public function index($options = array())
		{
			if ($this->get('simple'))
			{
				foreach (qa("SELECT * FROM `##{$this->id}` ORDER BY `priority`") as $row)
					if ($row['meta_url'.LL])
						Router::add(Router::TYPE_EQUALS, __('get-url', null, '') . $row['meta_url'.LL], array('page.location' => $this->id.'/get', 'page.pagesId' => $row['id']));
				Router::process();
				if (page()->location("{$this->id}/get"))
				{
					$_REQUEST['id'] = page()->pagesId;
					$this->mainTemplate();
				}
			}
			else
			{
				Router::add(Router::TYPE_EQUALS, __('get-url'), array('page.location' => $this->id.'/get'));
				Router::add(Router::TYPE_REGEX, __('get-url').'(.*)-(\d+)', array('page.location' => $this->id.'/get'), array('title', 'id'));
				Router::process();
				if (page()->location("{$this->id}/get"))
					$this->mainTemplate();
			}
		}

		public function page($options = array())
		{
			if (page()->location("{$this->id}/get"))
			{
				$url = $this->url('get');
				$module_title = __('module-title', $this->id, false);
				if ($module_title === false)
					$module_title = __('module-name', $this->id);
				if ($module_title)
					page()->breadcrumb($module_title, $this->url('get'));
				if (i()->get('id'))
				{
					foreach ($GLOBALS['result']['parents']->reverse() as $object)
						page()->breadcrumb($object->title, $this->url('get') . $object->url);				
					page()->breadcrumb($object->title, $this->url('get') . $object->url);
					page()->breadcrumb($GLOBALS['result']['object']->oid ? $GLOBALS['result']['object']->otitle : __('not-found', '@core'));
				}
				return true;
			}
		}

		/************************************************** ACTIONS **************************************************/
	}
?>

ACC SHELL 2018