public function getPostDetailMenuItems($post) {
        $template_path = Utils::getPluginViewDirectory('hellothinkup').'hellothinkup.inline.view.tpl';
        $menu_items = array();

        //Define a menu item
        $hello_menu_item_1 = new MenuItem("Data vis 1", "First data visualization", $template_path,
        'Hello ThinkUp Plugin Menu Header');
        //Define a dataset to be displayed when that menu item is selected
        $hello_menu_item_dataset_1 = new Dataset("replies_1", 'PostDAO', "getRepliesToPost",
        array($post->post_id, $post->network, 'location') );
        //Associate dataset with menu item
        $hello_menu_item_1->addDataset($hello_menu_item_dataset_1);
        //Add menu item to menu items array
        $menu_items['data_vis_1'] = $hello_menu_item_1;

        //Define a menu item
        $hello_menu_item_2 = new MenuItem("Data vis 2", "Second data visualization", $template_path);
        //Define a dataset to be displayed when that menu item is selected
        $hello_menu_item_dataset_2 = new Dataset("replies_2", 'PostDAO', "getRepliesToPost",
        array($post->post_id, $post->network, 'location') );
        //Associate dataset with menu item
        $hello_menu_item_2->addDataset($hello_menu_item_dataset_2);
        //Add menu item to menu items array
        $menu_items['data_vis_2'] = $hello_menu_item_2;

        return $menu_items;
    }
    public function getPostDetailMenuItems($post) {
        $menus = array();
        $map_template_path = Utils::getPluginViewDirectory('geoencoder').'geoencoder.map.tpl';

        //Define a menu item
        $map_menu_item = new MenuItem("Response Map", "", $map_template_path, 'Geoencoder');
        //Define a dataset to be displayed when that menu item is selected
        $map_menu_item_dataset_1 = new Dataset("geoencoder_map", 'PostDAO', "getRelatedPosts",
        array($post->post_id, $post->network, 'location') );
        //Associate dataset with menu item
        $map_menu_item->addDataset($map_menu_item_dataset_1);
        //Add menu item to menu
        $menus["geoencoder_map"] = $map_menu_item;

        $nearest_template_path = Utils::getPluginViewDirectory('geoencoder').'geoencoder.nearest.tpl';
        //Define a menu item
        $nearest_menu_item = new MenuItem("Nearest Responses", "", $nearest_template_path);
        //Define a dataset to be displayed when that menu item is selected
        $nearest_dataset = new Dataset("geoencoder_nearest", 'PostDAO', "getRelatedPosts",
        array($post->post_id, $post->network, !Session::isLoggedIn()));
        //Associate dataset with menu item
        $nearest_menu_item->addDataset($nearest_dataset);
        $nearest_dataset_2 = new Dataset("geoencoder_options", 'PluginOptionDAO', 'getOptionsHash',
        array('geoencoder', true));
        $nearest_menu_item->addDataset($nearest_dataset_2);
        //Add menu item to menu
        $menus["geoencoder_nearest"] = $nearest_menu_item;

        return $menus;
    }
Example #3
0
 function write_child()
 {
     $all_childs = $this->data["childs"];
     $child = new MenuItem($this->menu_layout_dir, $all_childs[$this->current_index], $this->level + 1);
     $this->current_index += 1;
     $child->render();
 }
Example #4
0
 function __construct()
 {
     //-----vytvorenie objektu menu
     $menu = new MenuItem();
     $menu->menuAction();
     //-----vytvorenie objektu node
     $node = new node();
     $node->nodeAction();
     MT::addContent($menu->render(), 'leftHolder');
     try {
         if (isset($_GET['id_menu_item']) or isset($_GET['addMenuItem']) or isset($_GET['changeMenuItem'])) {
             MT::addTemplate(APP_DIR . '/templates/admin/modulHolder.phtml', 'modulHolder');
             MT::addVar('modulHolder', 'type_modul', dibi::fetchAll("SELECT * FROM [type_modul] WHERE visible_for_user='******'"));
         }
         //zobrazenie zmeny polozky pre menu
         if (isset($_GET['changeMenuItem'])) {
             $menu->showChangeMenuItem($_GET['id_menu_item']);
         }
         if (isset($_GET['id_menu_item']) and !isset($_GET['changeMenuItem'])) {
             $node->showModul();
         }
         //pridanie polozky do menu
         if (isset($_GET['addMenuItem'])) {
             $menu->showAddMenuItem();
         }
         //zachytenie vynimie
     } catch (NodeException $e) {
         echo '<div style="border: 2px solid red; padding: 5px;">' . $e->getMessage() . '</div>';
         exit;
     }
 }
Example #5
0
 function __construct($page_object, $array_menu)
 {
     parent::__construct();
     $this->render = new Menu();
     $wsp_admin_url = WSP_ADMIN_URL;
     $menu_items = new MenuItems();
     foreach ($array_menu['MenuItems']['MenuItem'] as $menuitems) {
         eval("\$page_icon_16 = \"" . $menuitems['Menu_attr']['icon_16'] . "\";");
         if (find($menuitems['Menu_attr']['name'], "__(", 0, 0) > 0) {
             eval("\$page_title = " . $menuitems['Menu_attr']['name'] . ";");
         } else {
             eval("\$page_title = \"" . $menuitems['Menu_attr']['name'] . "\";");
         }
         eval("\$page_link = \"" . $menuitems['Menu_attr']['url'] . "\";");
         if ($menuitems['Menu_attr']['url'] == "\$wsp_admin_url/admin.html") {
             $page_title = "";
         }
         $menu_item = new MenuItem($page_title, $page_link, $page_icon_16);
         if (isset($_GET['menu'])) {
             if ($page_link == $wsp_admin_url . "/admin.html?menu=" . $_GET['menu']) {
                 $menu_item->setCurrent();
             }
         }
         $menu_items->add($menu_item);
         $sub_menu_items = new MenuItems();
         if (!isset($menuitems['MenuItems']['MenuItem'][0])) {
             $sub_menuitems = $menuitems['MenuItems'];
         } else {
             $sub_menuitems = $menuitems['MenuItems']['MenuItem'];
         }
         $nb_sub_menu = 0;
         foreach ($sub_menuitems as $menuitem) {
             eval("\$page_icon_16 = \"" . $menuitem['Menu_attr']['icon_16'] . "\";");
             if (find($menuitem['Menu_attr']['name'], "__(", 0, 0) > 0) {
                 eval("\$page_title = " . $menuitem['Menu_attr']['name'] . ";");
             } else {
                 eval("\$page_title = \"" . $menuitem['Menu_attr']['name'] . "\";");
             }
             eval("\$page_link = \"" . $menuitem['Menu_attr']['url'] . "\";");
             $sub_menu_item = new MenuItem($page_title, $page_link, $page_icon_16);
             if ($page_link == $_GET['p'] . ".html") {
                 $sub_menu_item->setCurrent();
                 $menu_item->setCurrent();
             }
             $sub_menu_items->add($sub_menu_item);
             $nb_sub_menu++;
         }
         if ($nb_sub_menu > 0) {
             $menu_item->setMenuItems($sub_menu_items);
         }
     }
     $this->render->setMenuItems($menu_items);
     $this->render->activateSupersubs();
     list($strAdminLogin, $strAdminPasswd, $strAdminRights) = getWspUserRightsInfo("admin");
     if ($strAdminLogin == "admin" && $strAdminPasswd == sha1("admin")) {
         $modalbox = new DialogBox(__(CHANGE_PASSWD), new Url($page_object->getBaseLanguageURL() . "wsp-admin/change-passwd.call"));
         $modalbox->modal()->setWidth(400);
         $page_object->addObject($modalbox);
     }
 }
Example #6
0
    public function createItem($name, array $options = array())
    {
        $item = new MenuItem($name, $this);

        $options = array_merge(
            array(
                'uri' => null,
                'label' => null,
                'attributes' => array(),
                'linkAttributes' => array(),
                'childrenAttributes' => array(),
                'labelAttributes' => array(),
                'display' => true,
                'displayChildren' => true,
            ),
            $options
        );

        $item
            ->setUri($options['uri'])
            ->setLabel($options['label'])
            ->setAttributes($options['attributes'])
            ->setLinkAttributes($options['linkAttributes'])
            ->setChildrenAttributes($options['childrenAttributes'])
            ->setLabelAttributes($options['labelAttributes'])
            ->setDisplay($options['display'])
            ->setDisplayChildren($options['displayChildren'])
        ;

        return $item;
    }
Example #7
0
 /**
  * Adiciona um item ao menu.
  * @param	string $name Texto que será exibido ao usuário
  * @param	string $link Link do item do menu
  * @return	MenuItem O item do menu recém adicionado
  */
 public function addItem($name, $link)
 {
     $menuItem = new MenuItem();
     $anchor = $menuItem->addChild(new Anchor($link));
     $anchor->addChild(new Text($name));
     $this->addChild($menuItem);
     return $menuItem;
 }
Example #8
0
 static function build($menu_name, $content_dir_name)
 {
     $final_root = self::get_menu_entries($content_dir_name);
     $final_root["key"] = $menu_name;
     $menu_layout_dir = new Dir(self::MENU_LAYOUT_FOLDER . $menu_name . "/");
     $root_item = new MenuItem($menu_layout_dir, $final_root, 0);
     $root_item->render();
 }
Example #9
0
 /**
  * Create a menu item from a NodeInterface
  *
  * @param NodeInterface $node
  * @return MenuItem
  */
 public function createFromNode(NodeInterface $node)
 {
     $item = new MenuItem($node->getName(), $this->getUriFromNode($node), $node->getAttributes());
     $item->setLabel($node->getLabel());
     foreach ($node->getChildren() as $childNode) {
         $item->addChild($this->createFromNode($childNode));
     }
     return $item;
 }
 /**
  * MenuItem constructor.
  */
 public function __construct($id)
 {
     $this->id = $id;
     if (is_null(static::$current)) {
         static::$current = $this;
         $this->level(0);
     } else {
         static::$current = addItem($this);
         $this->level(static::$current->level() + 1);
     }
 }
Example #11
0
 /**
  * Test constructor
  */
 public function testConstructor()
 {
     $tab = new MenuItem('my_short_name', "Name of My Tab");
     $this->assertEqual($tab->short_name, 'my_short_name');
     $this->assertEqual($tab->name, 'Name of My Tab');
     $this->assertEqual($tab->description, '');
     $this->assertEqual($tab->view_template, 'inline.view.tpl');
     $datasets = $tab->getDatasets();
     $this->assertIsA($datasets, 'array');
     $this->assertEqual(sizeof($datasets), 0);
 }
 /**
  * Creates new menuitem and adds it to items list
  *
  * @param string $name
  *            Internal name of item
  * @param string $text
  *            Text to show
  * @param string $url
  *            Optional url for linking
  *
  * @return MenuItem Reference to the created child item.
  */
 public function &createItem($name, $text, $url = '')
 {
     $menu_item = new MenuItem();
     $menu_item->setName($name);
     $menu_item->setText($text);
     if ($url) {
         $menu_item->setUrl($url);
     }
     $this->items[$name] = $menu_item;
     return $this->items[$name];
 }
 /**
  * Recursively creates a tree from the pages array
  *
  * @param   MenuItem parent         MenuItem object under which the tree is build
  * @param   array    pageIdx        indices of pages for this tree
  */
 private function buildTree(MenuItem &$parent, $pageIdx)
 {
     foreach ($pageIdx as $i) {
         if ($this->pages[$i]->parent == $parent->get('id')) {
             $child = $parent->addChild($this->pages[$i]);
             $this->buildTree($child, array_diff($pageIdx, array($i)));
             if ($this->pid == $this->pages[$i]->id) {
                 $parent->getRoot()->setCurrentItem($child);
             }
         }
     }
 }
Example #14
0
 public function getItems()
 {
     $user = Transaction::getInstance()->getUser();
     $items = array();
     foreach ($this->xml->item as $element) {
         $item = new MenuItem($this, $element);
         if ($item->getId() == $this->mainMenuId) {
             $item->setSelected(true);
         }
         if (!$item->isAdminOnly() || $user->isAdmin()) {
             $items[] = $item;
         }
     }
     return $items;
 }
 /**
  * Возвращает модель по указанному идентификатору
  * Если модель не будет найдена - возникнет HTTP-исключение.
  *
  * @param integer идентификатор нужной модели
  *
  * @return void
  *
  * @throws CHttpException If MenuItem record not found
  */
 public function loadModel($id)
 {
     if (($model = MenuItem::model()->findByPk($id)) === null) {
         throw new CHttpException(404, Yii::t('MenuModule.menu', 'Page was not found!'));
     }
     return $model;
 }
 public function loadModel($id)
 {
     if (($model = MenuItem::model()->findByPk($id)) === null) {
         throw new CHttpException(404, 'Страница не найдена');
     }
     return $model;
 }
Example #17
0
 public function deleteCategoryInfo($slug)
 {
     $results = \MenuCategory::where('menu_category_slug', '=', $slug)->get();
     foreach ($results as $result) {
         $id = $result->menu_category_id;
     }
     $items_using_cat = \MenuItem::where('menu_item_category_fk', '=', $id)->get();
     foreach ($items_using_cat as $item_using_cat) {
         if ($item_using_cat) {
             return \Redirect::to("admin/category/edit/{$slug}")->with('message', '<div class="alert alert-dismissible alert-danger alert-link">Unable to delete category. Please make sure no items are using this category.</p></div>');
         }
     }
     //if an item exists that has this cat's fk, reload the page with an error
     if (\Auth::check()) {
         \DB::beginTransaction();
         try {
             $statement = \MenuCategory::find($id);
             $statement->delete();
         } catch (ValidationException $e) {
             DB::rollback();
             throw $e;
         }
         \DB::commit();
         return \Redirect::to('admin')->with('message', '<div class="alert alert-dismissible alert-success alert-link">Category has been deleted</p></div>');
     }
     return \Redirect::to('admin');
 }
 public function run()
 {
     $array = array(['name' => 'Peluang Bisnis', 'link' => 'peluang', 'order' => '0', 'menu_id' => '1', 'visible' => '1'], ['name' => 'Artikel', 'link' => 'kategori/uncategorized', 'order' => '1', 'menu_id' => '1', 'visible' => '1'], ['name' => 'Syarat & Ketentuan', 'link' => 'pages/syarat-ketentuan', 'order' => '0', 'menu_id' => '2', 'visible' => '1'], ['name' => 'Privacy Policy', 'link' => 'pages/privacy-policy', 'order' => '1', 'menu_id' => '2', 'visible' => '1'], ['name' => 'Disclaimer', 'link' => 'pages/disclaimer', 'order' => '2', 'menu_id' => '2', 'visible' => '1']);
     foreach ($array as $item) {
         MenuItem::create($item);
     }
 }
Example #19
0
 /**
  * @method GET
  */
 function get($type)
 {
     $list = MenuItem::GetMenuItemsForType(SITE_ID, $type);
     $menu = array();
     foreach ($list as $row) {
         $scope = 'external';
         $pageUniqId = '';
         // set the scope of the link
         if ($row['PageId'] != '-1') {
             $scope = 'internal';
             $page = Page::GetByPageId($row['PageId']);
             if ($page != NULL) {
                 $pageUniqId = $page['PageUniqId'];
             }
         }
         // set the item
         $item = array('MenuItemUniqId' => $row['MenuItemUniqId'], 'Name' => $row['Name'], 'Url' => $row['Url'], 'PageUniqId' => $pageUniqId, 'Scope' => $scope);
         // push the item to the array
         array_push($menu, $item);
     }
     // return a json response
     $response = new Tonic\Response(Tonic\Response::OK);
     $response->contentType = 'application/json';
     $response->body = json_encode($menu);
     return $response;
 }
Example #20
0
 /**
  * Displays a particular model.
  * @param integer $id the ID of the model to be displayed
  */
 public function actionView($id = null, $path = null)
 {
     //if path is given, find the content_id from the menu item
     if ($path) {
         $Content = Content::model()->findByAttributes(array('path' => $path));
     } else {
         $Content = $this->loadModel($id);
     }
     $Content = $this->loadModel($id);
     $MI = MenuItem::model()->findByAttributes(array('content_id' => $Content->id));
     if (!Yii::app()->user->checkAccess('Update Content')) {
         $today = new DateTime();
         $publish_on = new DateTime($Content->publish_on);
         $unpublish_on = new DateTime($Content->unpublish_on);
         if (!$Content->published || $publish_on > $today || $unpublish_on < $today) {
             throw new CHttpException(403, Yii::t('yii', 'You are not authorized to perform this action.'));
         }
     }
     //$this->layout = '//layouts/column1';
     $view = 'view';
     if ($this->getLayoutFile('//layouts/content_types/' . $Content->type)) {
         $this->layout = '//layouts/content_types/' . $Content->type;
     }
     if ($this->getViewFile($Content->type)) {
         $view = $Content->type;
     }
     $this->meta_keywords = CHtml::value($Content, 'meta_keywords');
     $this->meta_description = CHtml::value($Content, 'meta_description');
     $this->meta_author = CHtml::value($Content, 'UserCreated.full_name');
     //Used by the admin bar
     $this->Content = $Content;
     $this->render($view, array('Content' => $Content, 'MenuItem' => $MI));
 }
Example #21
0
 /**
  * Overridden to specify what the child class should be
  */
 protected function createChild($name, $route = null, $attributes = array(), $class = null)
 {
     if (null === $class) {
         $class = $this->childClass;
     }
     return parent::createChild($name, $route, $attributes, $class);
 }
 /**
  * Scrapes all configured MenuSets under the NavigationScraper configuration item
  */
 public function scrapeConfiguredMenuSets()
 {
     $menuSetsToScrape = Config::inst()->get('NavigationScraper', 'MenuSets');
     $scraperService = Injector::inst()->create('NavigationScraperService');
     foreach ($menuSetsToScrape as $menuSet => $details) {
         $menuItems = $scraperService->scrape($details['PageToScrape'], $details['CSSSelector']);
         if (count($menuItems) == 0) {
             continue;
         }
         MenuItem::get()->filter(array('MenuSet' => $menuSet))->removeAll();
         foreach ($menuItems as $menuItemData) {
             $menuItem = new MenuItem(array('MenuSet' => $menuSet, 'LinkText' => $menuItemData['html'], 'LinkHref' => $menuItemData['href']));
             $menuItem->write();
         }
     }
 }
Example #23
0
 /**
  * Test constructor
  */
 public function testConstructor()
 {
     $menu_item = new MenuItem("Name of My Menu Item");
     $this->assertEqual($menu_item->name, 'Name of My Menu Item');
     $this->assertEqual($menu_item->description, '');
     $this->assertEqual($menu_item->view_template, 'inline.view.tpl');
     $this->assertEqual($menu_item->parent, null);
     $datasets = $menu_item->getDatasets();
     $this->assertIsA($datasets, 'array');
     $this->assertEqual(sizeof($datasets), 0);
     $menu_item1 = new MenuItem("Name of My Menu Item 1", 'descriptive text', 'mytemplate.tpl', "my-parent");
     $this->assertEqual($menu_item1->name, 'Name of My Menu Item 1');
     $this->assertEqual($menu_item1->description, 'descriptive text');
     $this->assertEqual($menu_item1->view_template, 'mytemplate.tpl');
     $this->assertEqual($menu_item1->parent, "my-parent");
 }
Example #24
0
 /**
  * set node and all subnodes selected
  */
 public function select()
 {
     $this->selected = true;
     if ($this->parent != null) {
         $this->parent->select();
     }
 }
Example #25
0
 public function run()
 {
     if (empty($this->template)) {
         return;
     }
     $url = trim(Yii::app()->request->url, '/');
     $items = MenuItem::model()->onSite()->byParent(0)->byMenuId($this->menuId)->orderDefault()->findAll();
     $itemsArr = array();
     foreach ($items as $item) {
         // Убираем язык из урла
         $domains = explode('/', ltrim($url, '/'));
         if (in_array($domains[0], array_keys(Yii::app()->params['languages']))) {
             array_shift($domains);
             $url = implode('/', $domains);
         }
         $select = strpos($url, trim($item->link, '/')) === 0 ? true : false;
         $blank = 0;
         if (strpos($item->link, 'http://') === 0 || strpos($item->link, 'https://') === 0) {
             $link = $item->link;
             $blank = 1;
         } else {
             $link = isset(Yii::app()->params['routes'][$item->link]) ? array('/' . Yii::app()->params['routes'][$item->link]) : '/' . $item->link;
             // Ссылка без языка, будет вести на дефолтную страницу
             $link = CHtml::normalizeUrl($link);
         }
         $iconUrl = $item->getIconUrl();
         $itemsArr[] = array('name' => $item->name, 'link' => $link, 'select' => $select, 'iconUrl' => $iconUrl, 'blank' => $blank, 'enabled' => $item->active);
     }
     $this->beforeRender($itemsArr);
     $this->render($this->template, array('items' => $itemsArr));
 }
Example #26
0
 protected function deleteMenu($menuId)
 {
     $menuItems = MenuItem::model()->findAllByAttributes(array('menuId' => $menuId));
     foreach ($menuItems as $item) {
         $item->delete();
     }
     Menu::model()->deleteByPk($menuId);
 }
Example #27
0
 public function showSingle($slug)
 {
     $slugs = MenuItem::where('menu_item_slug', '=', $slug)->get();
     foreach ($slugs as $slug) {
         $slug = $slug->menu_item_id;
     }
     return View::make('menu-items.single-item')->withSlug($slug);
 }
Example #28
0
 function getHTML($cls)
 {
     if (function_exists('getPageLinkURL')) {
         return parent::getHTML($cls);
     } else {
         return '';
     }
 }
Example #29
0
 /**
  * Menu constructor.
  * @param $children
  */
 public function __construct(array $children = array(), $displayName = null, $action = null, $iconClass = null, $className = null)
 {
     parent::__construct($displayName, $action, $iconClass, $className);
     if (is_null($children)) {
         $children = array();
     }
     $this->children = $children;
 }
Example #30
0
 public function renderItem(MenuItem $item)
 {
     $item->setAttribute('class', 'nav-item' . ($item->isCurrent() ? ' active' : ''));
     $item->setLinkAttribute('class', 'nav-link');
     //todo
     $item->setLinkAttribute('href', $item->getUrl());
     $item->setIconAttribute('class', $item->getIcon());
     //todo
     return soda_cms_view('partials.menu.item', compact('item'));
 }