Пример #1
0
 /**
  * Public function that creates a single instance
  */
 public static function getInstance()
 {
     if (!isset(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Пример #2
0
 /**
  * Display list of items associated with page and of specified type
  *
  * @param array $tag_params
  * @param array $children
  */
 public function tag_ItemList($tag_params, $children, $type)
 {
     $manager = UserPageItemsManager::getInstance();
     $page_id = isset($tag_params['page']) ? fix_id($tag_params['page']) : null;
     // create query conditions
     $conditions = array();
     if (!is_null($page_id)) {
         $conditions['page'] = $page_id;
     }
     $conditions['type'] = $type;
     // get items from database
     $items = $manager->getItems(array('id', 'item'), $conditions);
     if ($type == user_page::VIDEO) {
         // create template
         $template = $this->loadTemplate($tag_params, 'page_items_video.xml');
         // connect tag handlers
         if (class_exists('youtube')) {
             $module = youtube::getInstance();
             $template->registerTagHandler('_video', $module, 'tag_Video');
         }
     } else {
         // create template
         $template = $this->loadTemplate($tag_params, 'page_items_gallery.xml');
         // connect tag handlers
         if (class_exists('gallery')) {
             $module = gallery::getInstance();
             $template->registerTagHandler('_gallery', $module, 'tag_Group');
         }
     }
     // parse items
     if (count($items) > 0) {
         foreach ($items as $item) {
             $params = array('item' => $item->item, 'item_delete' => url_MakeHyperlink($this->getLanguageConstant('delete'), window_Open('user_pages_items_delete', 400, $this->getLanguageConstant('title_delete_page'), false, false, url_Make('transfer_control', 'backend_module', array('module', $this->name), array('backend_action', 'page_items_delete'), array('id', $item->id)))));
             $template->restoreXML();
             $template->setLocalParams($params);
             $template->parse();
         }
     }
 }