Ejemplo n.º 1
0
 protected function getBackendModulePath()
 {
     if ($this->URL->getModule() == 'Core') {
         return BACKEND_PATH . '/' . $this->URL->getModule();
     } else {
         return BACKEND_MODULES_PATH . '/' . $this->URL->getModule();
     }
 }
Ejemplo n.º 2
0
 /**
  * Parse the header into the template
  */
 public function parse()
 {
     // put the page title in the <title>
     $this->tpl->assign('page_title', BL::getLabel($this->URL->getModule()));
     // parse CSS
     $this->parseCSS();
     // parse JS
     $this->parseJS();
 }
Ejemplo n.º 3
0
 /**
  * This method exists because the service container needs to be set before
  * the page's functionality gets loaded.
  */
 public function initialize()
 {
     $url = new Url($this->getKernel());
     new TwigTemplate();
     new Navigation($this->getKernel());
     new Header($this->getKernel());
     $this->action = new Action($this->getKernel());
     $this->action->setModule($url->getModule());
     $this->action->setAction($url->getAction());
 }
Ejemplo n.º 4
0
 /**
  * Try to determine the selected state
  *
  * @param array $value The value.
  * @param int   $key   The key.
  * @param array $keys  The previous marked keys.
  * @return mixed
  */
 private function compareURL(array $value, $key, $keys = array())
 {
     // create active url
     $activeURL = $this->URL->getModule() . '/' . $this->URL->getAction();
     // we use the lowercased versions in the url
     $activeURL = strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $activeURL));
     // add current key
     $keys[] = $key;
     // sub action?
     if (isset($value['selected_for']) && in_array($activeURL, (array) $value['selected_for'])) {
         return $keys;
     }
     // if the URL is available and same as the active one we have what we need.
     if (isset($value['url']) && $value['url'] == $activeURL) {
         if (isset($value['children'])) {
             // loop the children
             foreach ($value['children'] as $key => $value) {
                 // recursive here...
                 $subKeys = $this->compareURL($value, $key, $keys);
                 // wrap it up
                 if (!empty($subKeys)) {
                     return $subKeys;
                 }
             }
         }
         // fallback
         return $keys;
     }
     // any children
     if (isset($value['children'])) {
         // loop the children
         foreach ($value['children'] as $key => $value) {
             // recursive here...
             $subKeys = $this->compareURL($value, $key, $keys);
             // wrap it up
             if (!empty($subKeys)) {
                 return $subKeys;
             }
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * @param Form $form An instance of Form, the elements will be parsed in here.
  * @param int $metaId The metaID to load.
  * @param string $baseFieldName The field where the URL should be based on.
  * @param bool $custom Add/show custom-meta.
  *
  * @throws Exception
  */
 public function __construct(Form $form, $metaId = null, $baseFieldName = 'title', $custom = false)
 {
     // check if URL is available from the reference
     if (!BackendModel::getContainer()->has('url')) {
         throw new Exception('URL should be available in the reference.');
     }
     // get BackendURL instance
     $this->URL = BackendModel::getContainer()->get('url');
     // should we use meta-custom
     $this->custom = (bool) $custom;
     // set form instance
     $this->frm = $form;
     // set base field name
     $this->baseFieldName = (string) $baseFieldName;
     // metaId was specified, so we should load the item
     if ($metaId !== null) {
         $this->loadMeta($metaId);
     }
     // set default callback
     $this->setURLCallback('Backend\\Modules\\' . $this->URL->getModule() . '\\Engine\\Model', 'getURL');
     // load the form
     $this->loadForm();
 }