/**
  * Main execution function
  * @param $par Parameters passed to the page
  */
 function execute($par)
 {
     global $wgRequest, $wgOut, $wgMakeBotPrivileged, $wgUser;
     $this->setHeaders();
     if ($par) {
         $this->target = $par;
     } else {
         $this->target = $wgRequest->getVal('target', wfMsg('rootcategory'));
     }
     $this->target = trim($this->target);
     #HACK for undefined root category
     if ($this->target == '<rootcategory>' || $this->target == '&lt;rootcategory&gt;') {
         $this->target = NULL;
     }
     $this->mode = $wgRequest->getVal('mode', CT_MODE_CATEGORIES);
     if ($this->mode == 'all') {
         $this->mode = CT_MODE_ALL;
     } else {
         if ($this->mode == 'pages') {
             $this->mode = CT_MODE_PAGES;
         } else {
             if ($this->mode == 'categories') {
                 $this->mode = CT_MODE_CATEGORIES;
             }
         }
     }
     $this->mode = (int) $this->mode;
     $wgOut->addWikiText(wfMsgNoTrans('categorytree-header'));
     $wgOut->addHtml($this->makeInputForm());
     if ($this->target !== '' && $this->target !== NULL) {
         CategoryTree::setHeaders($wgOut);
         $title = CategoryTree::makeTitle($this->target);
         if ($title && $title->getArticleID()) {
             $html = '';
             $html .= wfOpenElement('div', array('class' => 'CategoryTreeParents'));
             $html .= wfElement('span', array('class' => 'CategoryTreeParents'), wfMsg('categorytree-parents')) . ': ';
             $ct = new CategoryTree();
             $parents = $ct->renderParents($title, $this->mode);
             if ($parents == '') {
                 $html .= wfMsg('categorytree-nothing-found');
             } else {
                 $html .= $parents;
             }
             $html .= wfCloseElement('div');
             $html .= wfOpenElement('div', array('class' => 'CategoryTreeResult'));
             $html .= $ct->renderNode($title, $this->mode, true, false);
             $html .= wfCloseElement('div');
             $wgOut->addHtml($html);
         } else {
             $wgOut->addHtml(wfOpenElement('div', array('class' => 'CategoryTreeNotice')));
             $wgOut->addWikiText(wfMsg('categorytree-not-found', $this->target));
             $wgOut->addHtml(wfCloseElement('div'));
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Main execution function
  * @param $par array Parameters passed to the page
  */
 function execute($par)
 {
     global $wgCategoryTreeDefaultOptions, $wgCategoryTreeSpecialPageOptions, $wgCategoryTreeForceHeaders;
     $this->setHeaders();
     $request = $this->getRequest();
     if ($par) {
         $this->target = $par;
     } else {
         $this->target = $request->getVal('target', wfMessage('rootcategory')->text());
     }
     $this->target = trim($this->target);
     # HACK for undefined root category
     if ($this->target == '<rootcategory>' || $this->target == '&lt;rootcategory&gt;') {
         $this->target = null;
     }
     $options = array();
     # grab all known options from the request. Normalization is done by the CategoryTree class
     foreach ($wgCategoryTreeDefaultOptions as $option => $default) {
         if (isset($wgCategoryTreeSpecialPageOptions[$option])) {
             $default = $wgCategoryTreeSpecialPageOptions[$option];
         }
         $options[$option] = $request->getVal($option, $default);
     }
     $this->tree = new CategoryTree($options);
     $output = $this->getOutput();
     $output->addWikiMsg('categorytree-header');
     $this->executeInputForm();
     if ($this->target !== '' && $this->target !== null) {
         if (!$wgCategoryTreeForceHeaders) {
             CategoryTree::setHeaders($output);
         }
         $title = CategoryTree::makeTitle($this->target);
         if ($title && $title->getArticleID()) {
             $output->addHTML(Xml::openElement('div', array('class' => 'CategoryTreeParents')));
             $output->addHTML(wfMessage('categorytree-parents')->parse());
             $output->addHTML(wfMessage('colon-separator')->escaped());
             $parents = $this->tree->renderParents($title);
             if ($parents == '') {
                 $output->addHTML(wfMessage('categorytree-no-parent-categories')->parse());
             } else {
                 $output->addHTML($parents);
             }
             $output->addHTML(Xml::closeElement('div'));
             $output->addHTML(Xml::openElement('div', array('class' => 'CategoryTreeResult')));
             $output->addHTML($this->tree->renderNode($title, 1));
             $output->addHTML(Xml::closeElement('div'));
         } else {
             $output->addHTML(Xml::openElement('div', array('class' => 'CategoryTreeNotice')));
             $output->addHTML(wfMessage('categorytree-not-found', $this->target)->parse());
             $output->addHTML(Xml::closeElement('div'));
         }
     }
 }
Exemplo n.º 3
0
 function getCategoryTree()
 {
     global $wgOut, $wgCategoryTreeCategoryPageOptions, $wgCategoryTreeForceHeaders;
     if (!isset($this->categorytree)) {
         if (!$wgCategoryTreeForceHeaders) {
             CategoryTree::setHeaders($wgOut);
         }
         $this->categorytree = new CategoryTree($wgCategoryTreeCategoryPageOptions);
     }
     return $this->categorytree;
 }
Exemplo n.º 4
0
 public function actionList()
 {
     $canPublishNews = Yii::$app->user->can('tpbs.pond.approve');
     $request = Yii::$app->request;
     $op = $request->post('op', '');
     if (empty($op)) {
         $op = $request->get('op', '');
     }
     switch ($op) {
         case 'delete':
             $this->pondDelete();
             break;
     }
     $status = $request->post('status', '');
     if (empty($status)) {
         $status = $request->get('status', '');
     }
     $pondType = $request->post('pondType', 0);
     if (empty($pondType)) {
         $pondType = $request->get('pondType', 0);
     }
     $categoryId = $request->post('categoryId', 0);
     if (empty($categoryId)) {
         $categoryId = $request->get('categoryId', 0);
     }
     $dateStart = $request->post('dateStart', 0);
     if (empty($dateStart)) {
         $dateStart = $request->get('dateStart', 0);
     }
     $dateEnd = $request->post('dateEnd', 0);
     if (empty($dateEnd)) {
         $dateEnd = $request->get('dateEnd', 0);
     }
     $order = $request->post('order', 0);
     if (empty($order)) {
         $order = $request->get('order', 0);
     }
     $q = $request->post('q', '');
     if (empty($q)) {
         $q = $request->get('q', '');
     }
     $query = pond::find();
     if (!empty($status)) {
         $query->andWhere('status=:status', [':status' => $status]);
     }
     if (!empty($pondType)) {
         $query->andWhere('type=:type', [':type' => $pondType]);
     }
     if (!empty($datetStart) && empty($datetEnd)) {
         $query->andWhere(['LIKE', 'createTime', $datetStart]);
     }
     if (!empty($dateStart) && !empty($dateEnd)) {
         $query->andWhere(['between', 'createTime', $dateStart, $dateEnd]);
     }
     if (!empty($categoryId) && $categoryId != 0) {
         switch ($pondType) {
             case pond::TYPE_ONLINE_NEWS:
                 $type = 'news';
                 break;
             case pond::TYPE_ARTICLE:
                 $type = 'column';
                 break;
             default:
                 $type = 'news';
                 break;
         }
         $node = CategoryTree::getNode($categoryId);
         $query->andWhere(['in', 'categoryId', $node->getChildren($type, true)]);
     }
     if ($op == "search") {
         if (!empty($_REQUEST['type'])) {
             $type = $_REQUEST['type'];
             if ($type != 0) {
                 $query->andWhere('type=:type', [':type' => $type]);
             }
         }
         if (!empty($_REQUEST['q'])) {
             $item = $_REQUEST['q'];
             $query->andWhere(['LIKE', 'title', '%' . $item . '%', false]);
         }
     }
     $query->orderBy('lastUpdateTime DESC');
     if (!empty($q)) {
         $query->andWhere(['LIKE', 'title', $q]);
     }
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['ui']['defaultPageSize'], 'totalCount' => $query->count()]);
     $query->offset($pagination->offset);
     $query->limit($pagination->limit);
     $lst = $query->all();
     $pagination->params = ['page' => $pagination->page, 'status' => $status, 'pondType' => $pondType, 'categoryId' => $categoryId, 'order' => $order, 'q' => $q];
     $arrUserId = [];
     $arrUser = [];
     $arrPond = [];
     if ($lst) {
         foreach ($lst as $fields) {
             if ($fields->lastUpdateBy) {
                 array_push($arrUserId, $fields->lastUpdateBy);
             } else {
                 array_push($arrUserId, $fields->createBy);
             }
         }
     }
     $query = User::find();
     if (!empty($arrUserId)) {
         $query->andWhere(['in', 'id', $arrUserId]);
     }
     $user = $query->all();
     if ($user) {
         foreach ($user as $object) {
             $arrUser[$object->id] = $object->firstName . ' - ' . $object->lastName;
         }
     }
     $query = Typelist::find();
     $query->orderBy(['id' => SORT_ASC]);
     $objTypelist = $query->all();
     $arrTypelist = [];
     foreach ($objTypelist as $dataTypelist) {
         $arrTypelist[$dataTypelist->id] = $dataTypelist->name;
     }
     //var_dump($arrTypelist); exit();
     echo $this->render('list', ['lst' => $lst, 'arrUser' => $arrUser, 'status' => $status, 'pondType' => $pondType, 'categoryId' => $categoryId, 'order' => $order, 'q' => $q, 'pagination' => $pagination, 'canPublishNews' => $canPublishNews, 'arrTypelist' => $arrTypelist]);
 }
 /**
  * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
  * load CategoryTreeFunctions.php on demand.
  */
 function getTag(&$parser, $category, $mode, $hideroot = false, $style = '', $depth = 1)
 {
     global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
     static $uniq = 0;
     $this->mIsAjaxRequest = false;
     $category = trim($category);
     if ($category === '') {
         return false;
     }
     if ($wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag) {
         $parser->disableCache();
     }
     $title = self::makeTitle($category);
     if ($title === false || $title === NULL) {
         return false;
     }
     $html = '';
     $html .= wfOpenElement('div', array('class' => 'CategoryTreeTag', 'style' => $style));
     if (!$title->getArticleID()) {
         $html .= wfOpenElement('span', array('class' => 'CategoryTreeNotice'));
         $html .= self::msg('not-found', htmlspecialchars($category));
         $html .= wfCloseElement('span');
     } else {
         if (!$hideroot) {
             $html .= CategoryTree::renderNode($title, $mode, $depth > 0, $wgCategoryTreeDynamicTag, $depth - 1);
         } else {
             if (!$wgCategoryTreeDynamicTag) {
                 $html .= $this->renderChildren($title, $mode, $depth - 1);
             } else {
                 //FIXME: depth would need to be propagated here. this would imact the cache key, too
                 $uniq += 1;
                 $load = 'ct-' . $uniq . '-' . mt_rand(1, 100000);
                 $html .= wfOpenElement('script', array('type' => 'text/javascript', 'id' => $load));
                 $html .= 'categoryTreeLoadChildren("' . Xml::escapeJsString($title->getDBkey()) . '", "' . $mode . '", document.getElementById("' . $load . '").parentNode );';
                 $html .= wfCloseElement('script');
             }
         }
     }
     $html .= wfCloseElement('div');
     $html .= "\n\t\t";
     return $html;
 }
function GetCategory($point)
{
    $data = '';
    $data = '<option value="0" selected="selected"></option>';
    $tree = new CategoryTree($point);
    $data .= $tree->GetData();
    return $data;
}
Exemplo n.º 7
0
function efCategoryTreeGetConfigVars(&$vars)
{
    global $wgCategoryTreeCategoryPageOptions;
    // Look this is pretty bad but Category tree is just whacky, it needs to be rewritten
    $ct = new CategoryTree($wgCategoryTreeCategoryPageOptions);
    $vars['wgCategoryTreePageCategoryOptions'] = $ct->getOptionsAsJsStructure();
    return true;
}
 function makeShowAsLink($targetValue, $currentValue)
 {
     $msg = htmlspecialchars(CategoryTree::msg("show-{$targetValue}"));
     if ($targetValue == $currentValue) {
         return "<strong>{$msg}</strong>";
     } else {
         return $this->getSkin()->makeKnownLinkObj($this->title, $msg, "showas={$targetValue}");
     }
 }
Exemplo n.º 9
0
 /**
  * Custom tag implementation. This is called by efCategoryTreeParserHook, which is used to
  * load CategoryTreeFunctions.php on demand.
  */
 function getTag($parser, $category, $hideroot = false, $attr, $depth = 1, $allowMissing = false)
 {
     global $wgCategoryTreeDisableCache, $wgCategoryTreeDynamicTag;
     static $uniq = 0;
     $category = trim($category);
     if ($category === '') {
         return false;
     }
     if ($parser && $wgCategoryTreeDisableCache && !$wgCategoryTreeDynamicTag) {
         $parser->disableCache();
     }
     $title = self::makeTitle($category);
     if ($title === false || $title === NULL) {
         return false;
     }
     if (isset($attr['class'])) {
         $attr['class'] .= ' CategoryTreeTag';
     } else {
         $attr['class'] = ' CategoryTreeTag';
     }
     $this->init();
     $html = '';
     $html .= Xml::openElement('div', $attr);
     if (!$allowMissing && !$title->getArticleID()) {
         $html .= Xml::openElement('span', array('class' => 'CategoryTreeNotice'));
         $html .= wfMsgExt('categorytree-not-found', 'parseinline', htmlspecialchars($category));
         $html .= Xml::closeElement('span');
     } else {
         if (!$hideroot) {
             $html .= CategoryTree::renderNode($title, $depth, $wgCategoryTreeDynamicTag);
         } else {
             if (!$wgCategoryTreeDynamicTag) {
                 $html .= $this->renderChildren($title, $depth);
             } else {
                 $uniq += 1;
                 $load = 'ct-' . $uniq . '-' . mt_rand(1, 100000);
                 $html .= Xml::openElement('script', array('type' => 'text/javascript', 'id' => $load));
                 $html .= 'categoryTreeLoadChildren("' . Xml::escapeJsString($title->getDBkey()) . '", ' . $this->getOptionsAsJsStructure($depth) . ', document.getElementById("' . $load . '").parentNode);';
                 $html .= Xml::closeElement('script');
             }
         }
     }
     $html .= Xml::closeElement('div');
     $html .= "\n\t\t";
     return $html;
 }
 /**
  * @param int $id
  * @param  $ebay_global_id
  * @throws CHttpException
  */
 public function actionIndex($id = 0, $ebay_global_id = false)
 {
     Yii::import('application.vendors.CategoryTree');
     if (empty($id)) {
         $model = new SearchRequests();
         //$model->unsetAttributes();  // clear any default values
         if (empty($ebay_global_id)) {
             $ebay_global_id = 'EBAY-US';
         }
         $model->ebay_global_id = $ebay_global_id;
     } else {
         $model = $this->loadModel($id);
         if (!empty($ebay_global_id)) {
             $model->ebay_global_id = $ebay_global_id;
         } else {
             $ebay_global_id = $model->ebay_global_id;
         }
     }
     if (isset($_POST['SearchRequests'])) {
         $attributes = $_POST['SearchRequests'];
         if (isset($_POST['request_type']) and $_POST['request_type'] == 'new') {
             //$model->is
             $model->isNewRecord = true;
             $model->id = null;
             unset($attributes['id']);
         }
         if ($model->isNewRecord) {
             $attributes['user_id'] = WebUser::Id(true);
         }
         $attributes['date_update'] = time();
         $model->attributes = $attributes;
         if ($model->save()) {
             $this->redirect(array('listing', 'id' => $model->id));
         } else {
             $this->setFlashError(Yii::t('sniper_ebay', 'Correct those fields and try again'));
         }
     }
     $categories = false;
     if (empty($categories)) {
         $categoriesAPI = new GetCategoriesClass();
         $categories[0] = 'All';
         try {
             $ebay_site_id = SearchRequests::model()->getSiteEbayId($ebay_global_id);
             $categoriesAPI->siteID = $ebay_site_id;
             if ($ebay_global_id == 'EBAY-MOTOR') {
                 $categoriesAPI->levelLimit = 4;
             }
             $ebay_cats = $categoriesAPI->makeAPICall();
             $cats_attributes = array();
             $categories_tree = array();
             foreach ($ebay_cats as $_e_category) {
                 $cats_attributes[] = array('ebay_category_id' => (int) $_e_category->CategoryID, 'category_name' => (string) $_e_category->CategoryName, 'ebay_category_level' => (int) $_e_category->CategoryLevel, 'ebay_parent_id' => (int) $_e_category->CategoryParentID, 'auto_pay' => $_e_category->AutoPayEnabled == 'true' ? 1 : 0, 'best_offer' => $_e_category->BestOfferEnabled == 'true' ? 1 : 0);
                 $categories[(int) $_e_category->CategoryID] = (string) $_e_category->CategoryName;
                 $_id = (int) $_e_category->CategoryID;
                 $_parent_id = (int) $_e_category->CategoryParentID;
                 $categories_tree[] = array('id' => $_id, 'parent_id' => $_id == $_parent_id ? 0 : $_parent_id, 'title' => (string) $_e_category->CategoryName);
             }
             $tree = new CategoryTree($categories_tree);
             $categories = $tree->getOneDimTree();
             //Categories::model()->saveMultiple($cats_attributes);
         } catch (Exception $ex) {
             $this->setFlashError($ex->getMessage());
         }
     } else {
         $categories = CHtml::listData($categories, 'ebay_category_id', 'category_name');
     }
     $data = array('categories' => $categories, 'model' => $model);
     $this->render('index', $data);
 }
Exemplo n.º 11
0
function addCourse()
{
    checkPerm('mod');
    require_once _base_ . '/lib/lib.form.php';
    //require_once(_i18n_.'/lib.lang.php');
    require_once _base_ . '/lib/lib.table.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.course.php';
    require_once dirname(__FILE__) . '/../category/category.php';
    require_once dirname(__FILE__) . '/../category/tree.category.php';
    require_once $GLOBALS['where_lms'] . '/lib/lib.manmenu.php';
    require_once $GLOBALS['where_lms'] . '/lib/category/class.categorytree.php';
    $form = new Form();
    $lang =& DoceboLanguage::CreateInstance('course', 'lms');
    // tree for categories ------------------------------------------------
    $categoryDb = new CategoryTree();
    $id_category = isset($_SESSION['course_category']['filter_status']['c_category']) ? (int) $_SESSION['course_category']['filter_status']['c_category'] : 0;
    $name_category = $categoryDb->getFolderById($id_category);
    $name_category = end(explode("/", $name_category->path));
    // -------------------------------------------------------------------
    $course = array('autoregistration_code' => '', 'code' => '', 'name' => '', 'lang_code' => getLanguage(), 'difficult' => 'medium', 'course_type' => 'elearning', 'status' => CST_EFFECTIVE, 'course_edition' => 0, 'description' => '', 'can_subscribe' => 1, 'sub_start_date' => '', 'sub_end_date' => '', 'show_rules' => 0, 'show_progress' => 1, 'show_time' => 1, 'show_who_online' => 1, 'show_extra_info' => 0, 'level_show_user' => 0, 'subscribe_method' => 2, 'selling' => 0, 'prize' => '', 'advance' => '', 'permCloseLO' => 0, 'userStatusOp' => 1 << _CUS_SUSPEND, 'direct_play' => 0, 'date_begin' => '', 'date_end' => '', 'hour_begin' => '-1', 'hour_end' => '-1', 'valid_time' => '0', 'mediumTime' => '0', 'min_num_subscribe' => '0', 'max_num_subscribe' => '0', 'allow_overbooking' => '', 'course_quota' => '', 'show_result' => '0', 'linkSponsor' => 'http://', 'use_logo_in_courselist' => '1');
    // -------------------------------------------------------------------
    $title_area = array('index.php?modname=course&amp;op=course_list' => $lang->def('_COURSE'), $lang->def('_NEW_COURSE'));
    cout(getTitleArea($title_area, 'course') . '<div class="std_block">' . getBackUi('index.php?modname=course&amp;op=course_list', $lang->def('_BACK')) . $form->getFormHeader($lang->def('_NEW_COURSE')) . $form->openForm('course_creation', 'index.php?modname=course&amp;op=add_course', false, false, 'multipart/form-data') . $form->getHidden('idCategory', 'idCategory', $id_category), 'content');
    maskModCourse($course, true, $name_category);
    $GLOBALS['page']->add($form->openButtonSpace() . $form->getButton('course_create', 'course_create', $lang->def('_CREATE')) . $form->getButton('course_undo', 'course_undo', $lang->def('_UNDO')) . $form->closeButtonSpace() . $form->closeForm() . '</div>', 'content');
}
Exemplo n.º 12
0
/**
* Hook callback that injects messages and things into the <head> tag
* Does nothing if $parserOutput->mCategoryTreeTag is not set
*/
function efCategoryTreeParserOutput(&$outputPage, &$parserOutput)
{
    if (!empty($parserOutput->mCategoryTreeTag)) {
        CategoryTree::setHeaders($outputPage);
    }
    return true;
}