Exemple #1
0
 /**
  * shortcut call \Flywheel\Router\WebRouter::createUrl() method
  * @see \Flywheel\Router\WebRouter::createUrl()
  * @param $route
  * @param array $params
  * @param bool $absolute
  * @param string $ampersand
  * @return mixed
  */
 public function createUrl($route, $params = array(), $ampersand = '&', $absolute = false)
 {
     $route = trim($route, '/');
     if ('post/detail' == $route) {
         if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
             $params['slug'] = $post->getSlug();
         }
     } else {
         if ('category/default' == $route) {
             if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                 $params['slug'] = $term->getSlug();
             }
         } else {
             if ('events/default' == $route) {
                 if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                     $params['slug'] = $term->getSlug();
                 }
             } else {
                 if ('events/detail' == $route) {
                     if (isset($params['id']) && ($post = \Posts::retrieveById($params['id']))) {
                         $params['slug'] = $post->getSlug();
                     }
                 }
             }
         }
     }
     $params = Plugin::applyFilters('custom_router_param', $route, $params);
     if ($this->currentLang && sizeof($this->languages) > 1) {
         $params['lang'] = $this->currentLang->getLangCode();
     }
     return parent::createUrl($route, $params, $ampersand, $absolute);
 }
 protected function _init()
 {
     parent::_init();
     $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR;
     $this->items = \CMSBackend\Library\MobileMenu::$items;
     $this->items = \Toxotes\Plugin::applyFilters('custom_admin_mobile_nav', $this->items);
 }
Exemple #3
0
 public function beforeExecute()
 {
     parent::beforeExecute();
     // TODO: Change the autogenerated stub
     $this->form_cfg = ['common' => ['label' => t('Common Settings'), 'settings' => ['site_name' => ['label' => t('Site Name'), 'control' => 'input', 'type' => 'text'], 'site_url' => ['label' => t('Site Url'), 'control' => 'input', 'type' => 'text', 'placeholder' => 'http://'], 'email_address' => ['label' => t('E-mail Address'), 'control' => 'input', 'type' => 'email'], 'contact_phone' => ['label' => t('Company Phone'), 'control' => 'input', 'type' => 'tel'], 'contact_address' => ['label' => t('Company Address'), 'control' => 'input', 'type' => 'text'], 'site_offline' => ['label' => t('Site Offline?'), 'control' => 'checkbox', 'value' => 1]]]];
     $other_setting = ConfigHandler::get('site_setting');
     if (!empty($other_setting)) {
         $this->form_cfg['common']['settings'] = Base::mergeArray($this->form_cfg['common']['settings'], $other_setting);
     }
     $this->form_cfg = Plugin::applyFilters('custom_system_setting', $this->form_cfg);
 }
Exemple #4
0
 public function end()
 {
     $select = $this->form->selectOption($this->elementName, $this->selected, (array) $this->htmlOptions)->addOption(t('Select Language'), '*');
     foreach ($this->languages as $lang) {
         $select->addOption($lang->getTitle(), $lang->getLangCode());
     }
     $select = \Toxotes\Plugin::applyFilters('dropdown_language', $select);
     ob_start();
     $select->display();
     $s = ob_get_clean();
     return $s;
 }
 public function begin()
 {
     $this->enable = Plugin::applyFilters('enable_' . $this->taxonomy . '_category', true);
     if (!$this->enable) {
         return;
     }
     $this->item_taxonomy = $this->taxonomy;
     if ($this->taxonomy == 'post') {
         $this->taxonomy = 'category';
     }
     $this->taxonomy = Plugin::applyFilters('get_category_' . $this->item_taxonomy, $this->taxonomy);
     parent::begin();
 }
Exemple #6
0
 protected function _init()
 {
     parent::_init();
     $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR;
     //f**k it
     foreach ($this->_menus as $m => $content) {
         $this->_menus[$m]['label'] = t($this->_menus[$m]['label']);
     }
     //Menu Widget
     $this->_addChildMenu('menu_widget', ['label' => t('Menu List'), 'url' => ['menu/default']]);
     $this->_addChildMenu('menu_widget', ['label' => t('Add Menu'), 'url' => ['menu/create']]);
     //Post
     $this->_addChildMenu('posts', ['label' => t('All Posts'), 'url' => ['post/default']]);
     $this->_addChildMenu('posts', ['label' => t('Compose New'), 'url' => ['post/create']]);
     $this->_addChildMenu('posts', ['label' => t('Categories'), 'url' => ['category/default', 'taxonomy' => 'category']]);
     $this->_addSiteContentMenu();
     $this->_addProductsMenu();
     $this->items = \Toxotes\Plugin::applyFilters('after_init_admin_main_nav', $this->items);
     $this->_addSystemMenu();
     $this->_buildMenu();
 }
Exemple #7
0
 public function beforeExecute()
 {
     parent::beforeExecute();
     // TODO: Change the autogenerated stub
     $document = $this->document();
     $document->title = \Setting::get('site_name');
     $this->_initTemplate();
     $this->_initLanguages();
     Plugin::addFilter('custom_router_param', function ($route, $params) {
         if ('products/category' == $route) {
             if (isset($params['id']) && ($term = \Terms::retrieveById($params['id']))) {
                 $params['slug'] = $term->getSlug();
             }
         }
         if ('products/detail' == $route) {
             if (isset($params['id']) && ($item = \Items::retrieveById($params['id']))) {
                 $params['slug'] = $item->getSlug();
             }
         }
         return $params;
     }, 1, 2);
 }
Exemple #8
0
 private function _propertyForm(\Terms $term, $taxonomy)
 {
     Plugin::applyFilters('term_property_form_' . $taxonomy);
     $controls = [];
     $propertiesOpt = Content::getTermPropertiesOpt($taxonomy);
     //form control
     foreach ($propertiesOpt as $key => $setting) {
         if (!$term->isNew()) {
             $setting['value'] = \TermProperty::getTermPropertyValue($term->getId(), $key);
         } else {
             $setting['value'] = '';
         }
         $name = "term_prop[{$key}]";
         $html_options = $setting;
         unset($html_options['label']);
         unset($html_options['value']);
         unset($html_options['control']);
         unset($html_options['options']);
         $controls[$key] = ['label' => isset($setting['label']) ? $setting['label'] : ''];
         switch ($setting['control']) {
             case 'input':
                 $object = new Input($name, $setting['value'], $html_options);
                 $object->setType($setting['type']);
                 unset($html_options['type']);
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'textarea':
                 $controls[$key]['controlObject'] = new TextArea($name, $setting['value'], $html_options);
                 break;
             case 'select':
                 $object = new SelectOption($name, $setting['value'], $html_options);
                 foreach (@$setting['options'] as $opt) {
                     $object->addOption($opt['label'], $opt['value'], @$opt['htmlOption']);
                 }
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'checkbox':
                 $object = new Checkbox($name, $setting['value'], $html_options);
                 $object->setExpectValue($setting['default']);
                 $controls[$key]['controlObject'] = $object;
                 break;
             case 'radio':
                 unset($html_options['options']);
                 $object = new RadioButton($name, $setting['value']);
                 foreach (@$setting['options'] as $opt) {
                     $object->add($opt['value'], $opt['label'], @$opt['htmlOption'], @$opt['inputOption']);
                 }
                 $controls[$key]['controlObject'] = $object;
                 break;
         }
     }
     return $controls;
 }
Exemple #9
0
 /**
  * Save post
  *
  * @param \Posts $post
  * @param $error
  * @return bool
  */
 protected function _save(\Posts &$post, &$error)
 {
     $isDraft = $post->getIsDraft();
     $input = $this->request()->post('post', 'ARRAY', array());
     $post->hydrate($input);
     $post->setExcerpt(nl2br($post->getExcerpt()));
     $post->setIsDraft(false);
     $error = Plugin::applyFilters('verify_' . $post->getTaxonomy() . '_form_data', $error);
     if (!$post->getAuthor()) {
         $post->setAuthor($this->getSessionUser()->getName());
     }
     if (!$post->isDraft() && !($post->getPublishTime() || $post->getPublishTime()->isEmpty())) {
         $post->setPublishTime(new DateTime());
     }
     if (empty($error) && $post->save()) {
         $post = Plugin::applyFilters('handling_' . $post->getTaxonomy() . '_form_data', $post);
         if ($isDraft) {
             $this->dispatch('after_publish_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post)));
         } else {
             $this->dispatch('after_save_' . $post->getTaxonomy() . '_post', new CMSBackendEvent($this, array('post' => $post)));
         }
         return true;
     } else {
         foreach ($post->getValidationFailures() as $validationFailure) {
             $error[$validationFailure->getColumn()] = $validationFailure->getMessage();
         }
     }
     return false;
 }
Exemple #10
0
 protected function _columnTool($item)
 {
     $s = '';
     $subtool = '';
     $subtool = '<div class="sub-tool">';
     $subtool = Plugin::applyFilters('custom_' . $item->taxonomy . '_subtool', $subtool);
     $s .= $subtool;
     $removeLink = Factory::getRouter()->createUrl('category/delete', array('id' => $item->id));
     $editLink = Factory::getRouter()->createUrl('category/edit', array('id' => $item->id));
     $s .= '<a href="' . $editLink . '" class="tool-link tool-edit">' . t('Edit') . '</a> | <a href="' . $removeLink . '" class="tool-link tool-remove" rel="term-' . $item->getId() . '">' . t('Remove') . '</a>';
     $s = Plugin::applyFilters('manage_' . $this->taxonomy . '_custom_tool_column', $s, $item->id);
     return $s;
 }
Exemple #11
0
 protected function _columnCustom($name, $item)
 {
     $value = null;
     if (isset($this->columns[$name]['value'])) {
         eval('$value = ' . $this->columns[$name]['value']);
     }
     if (isset($this->columns[$name]['callback'])) {
         $value = call_user_func_array($this->columns[$name]['callback'], array($name, $item, $value));
     }
     $value = Plugin::applyFilters('manage_' . $this->taxonomy . '_custom_column', $value, $name, $item->id);
     return $value;
 }
Exemple #12
0
 protected function _init()
 {
     parent::_init();
     $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR;
     $this->items = \Toxotes\Plugin::applyFilters('custom_admin_left_sidebar', $this->items);
 }
Exemple #13
0
 /**
  * Register default taxonomies
  */
 protected function _registerDefaultTaxonomies()
 {
     Plugin::registerTaxonomy('category', 'post', array('label' => t('Category'), 'enable_custom_fields' => true));
     Plugin::registerTaxonomy('banner', 'post', array('label' => t('Banner'), 'enable_custom_fields' => false));
     Plugin::registerTaxonomy('post', 'post', array('label' => t('Post')));
     Plugin::addFilter('term_property_form_category', function () {
         Content::addTermPropertyOpt('cat_view', ['label' => t('Category view'), 'control' => 'select', 'options' => Content::getCategoryTemplates()], 'category');
         Content::addTermPropertyOpt('post_ordering', ['label' => t('Posts ordering'), 'control' => 'select', 'options' => [['label' => t('Created time'), 'value' => 'created_time'], ['label' => t('Publish time'), 'value' => 'publish_time'], ['label' => t('Modified time'), 'value' => 'modified_time'], ['label' => t('Post order'), 'value' => 'ordering'], ['label' => t('Hit'), 'value' => 'hits']]], 'category');
         Content::addTermPropertyOpt('page_size', ['label' => t('Page size'), 'control' => 'input', 'type' => 'text', 'placeholder' => t('Number per page')], 'category');
         Content::addTermPropertyOpt('post_view', ['label' => t('Post view'), 'control' => 'select', 'options' => Content::getPostTemplates()], 'category');
     });
 }