function saveTerms() { if ($terms = $_POST['terms']) { $languages = (array) $CONFIG->Site->languages; $tid = $DB->aliases->getCell(array('alias' => 'Terms', 'id')); foreach ($languages as $l) { $tpage = new Terms($tid, $l); $tpage->saveContent(array('Terms' => $terms[$l])); } Flash::create(__('Your changes have been saved'), 'confirmation'); $_REQUEST->clear('view'); } }
/** * 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); }
public function begin() { $termId = $this->getParams('term_id'); $ordering = $this->getParams('ordering'); $fetchChild = $this->getParams('fetch_child', false); $q = Posts::read()->where('`status`=:status AND `is_draft` = 0')->setParameter(':status', 'PUBLISH', \PDO::PARAM_STR); $term = Terms::retrieveById($termId); if (!$term) { return; } if ($fetchChild) { $child = $term->getDescendants(); $ids = array($term->getId()); foreach ($child as $_c) { $ids[] = $_c->getId(); } $q->andWhere('`term_id` IN (' . implode(',', $ids) . ')'); } else { $q->andWhere('`term_id`=:term_id')->setParameter(':term_id', $term->getId(), \PDO::PARAM_INT); } //limit $limit = $this->getParams('limit'); if ($limit) { $q->setMaxResults((int) $limit); } if ($ordering) { foreach ($ordering as $_ordering) { $q->addOrderBy($_ordering['field'], $_ordering['order']); } } else { $q->addOrderBy('modified_time', 'DESC'); } $this->list = $q->execute()->fetchAll(\PDO::FETCH_CLASS, 'Posts', array(null, false)); }
public function executeCategory() { $id = $this->get('id'); if (!$id || !($term = \Terms::retrieveById($id))) { return $this->raise404(t('Product Category not found!')); } $cats = [$term->getId()]; $descendants = (array) $term->getDescendants(); foreach ($descendants as $d) { $cats[] = $d->getId(); } //create query $q = \Items::select(); if (sizeof($cats) > 1) { $q->where('`cat_id` = :cat_id')->setParameter(':cat_id', $term->getId(), \PDO::PARAM_INT); } else { $q->where('`cat_id` IN (' . implode(', ', $cats) . ')'); } $q->andWhere('`status` = "ACTIVE"')->andWhere('`is_draft` = 0'); //filter $price_from = floatval(str_replace(',', '.', str_replace('.', '', $this->get('price_from')))); $price_to = floatval(str_replace(',', '.', str_replace('.', '', $this->get('price_to')))); if ($price_from > $price_to) { $t = $price_from; $price_from = $price_to; $price_to = $t; } if ($price_from) { $q->andWhere('`regular_price` >= :pf OR `sale_price` >= :pf')->setParameter(':pf', $price_from, \PDO::PARAM_STR); } if ($price_to) { $q->andWhere('`regular_price` <= :pf OR `sale_price` <= :pf')->setParameter(':pf', $price_to, \PDO::PARAM_STR); } $ordering = $this->get('ordering'); switch ($ordering) { case 'PRICE_DESCENDING': $q->orderBy('regular_price', 'DESC')->addOrderBy('sale_price', 'DESC'); break; case 'PRICE_ASCENDING': $q->orderBy('regular_price', 'ASC')->addOrderBy('sale_price', 'ASC'); break; default: $q->orderBy('public_time', 'DESC'); } $cq = clone $q; $total = $cq->count('`id`')->execute(); $page = abs($this->get('page', 'INT', 1)); $items = $q->execute(); $this->setView('Products/category'); $this->view()->assign(['term' => $term, 'items' => $items, 'total' => $total, 'page' => $page, 'page_size' => $this->pageSize, 'price_form' => $price_from, 'price_to' => $price_to, 'ordering' => $ordering]); return $this->renderComponent(); }
/** * See if a term or set of terms is in this set of terms * * @param mixed $tags. A string containing a string or a comma separated list of strings, * or an array of strings, Terms, or a Term subclass * @return boolean. Whether the tag(s) is in the current set of tags. */ public function has($tags) { if (is_string($tags) || is_array($tags) && is_string($tags[0])) { $tags = (array) Terms::parse($tags); } $diff = array_diff($tags, (array) $this); foreach ($tags as $tag) { if (in_array($tag, $diff)) { return false; } } return true; }
public function begin() { $terms = $this->getParams('terms'); $ordering = $this->getParams('ordering'); $fetchChild = $this->getParams('fetch_child', false); $limit = $this->getParams('limit'); $q = \Items::select()->where('`is_draft` = 0 AND `status` = :status')->setParameter(':status', 'ACTIVE', \PDO::PARAM_STR); if (!empty($ordering)) { foreach ($ordering as $_o) { $q->addOrderBy(@$_o['field'], @$_o['order']); } } else { $q->orderBy('created_time', 'DESC'); } if ($limit) { $q->setMaxResults((int) $limit); } if (is_array($terms) && !empty($terms)) { $t = $terms; if ($fetchChild) { foreach ($terms as $term_id) { if ($term = \Terms::retrieveById($term_id)) { $descendants = (array) $term->getDescendants(); foreach ($descendants as $d) { $t[] = $d->getId(); } unset($d); } } } $terms = $t; $q->andWhere('`cat_id` IN (' . implode(', ', $terms) . ')'); } elseif (is_scalar($terms) && is_numeric($terms)) { $t = [$terms]; if ($term = \Terms::retrieveById($terms)) { if ($fetchChild) { $descendants = (array) $term->getDescendants(); foreach ($descendants as $d) { $t[] = $d->getId(); } unset($d); } } if (sizeof($t) > 1) { $q->andWhere('`cat_id` IN (' . implode(', ', $t) . ')'); } else { $q->andWhere('`cat_id` = :term_id')->setParameter(':term_id', $terms, \PDO::PARAM_INT); } } $this->items = $q->execute(); }
public function executeDefault() { $keyword = $this->get('keyword'); $cat_id = $this->get('cat_id'); $is_hot = $this->get('is_hot'); $promotion = $this->get('promotion'); $page = $this->get('page', 'INT', 1); if ($this->request()->isXmlHttpRequest()) { $ajax = new \AjaxResponse(); $q = \Items::read(); if ($keyword) { $q->where('`name` LIKE :k OR `slug` LIKE :k')->setParameter(':k', "%{$keyword}%", \PDO::PARAM_STR); } if ($cat_id) { $q->andWhere('`cat_id` = :cat_id')->setParameter(':cat_id', $cat_id, \PDO::PARAM_INT); } if ($is_hot) { $q->andWhere('`pin` = 1'); } if ($promotion) { $q->andWhere('`promotion` = 1'); } $cq = clone $q; $total = $cq->count('`id`')->execute(); $stmt = $q->setMaxResults(30)->setFirstResult(30 * ($page - 1))->execute(); $result = []; while ($om = $stmt->fetchObject(\Items::getPhpName(), [null, false])) { /** @var \Items $om */ $t = $om->toArray(); $t['cat'] = \Terms::retrieveById($om->getCatId()); if ($t['cat']) { $t['cat'] = $t['cat']->toArray(); } $t['thumb_url'] = $om->getMainImgThumb(96); $t['edit_link'] = $this->createUrl('items/edit', ['id' => $om->getId()]); $t['remove_link'] = $this->createUrl('items/remove', ['id' => $om->getId()]); $result[] = $t; } $ajax->type = \AjaxResponse::SUCCESS; $ajax->items = $result; $ajax->current_page = $page; $ajax->total_page = ceil($total / 30); return $this->renderText($ajax->toString()); } $this->document()->addJsVar('items_list_url', $this->createUrl('items')); $this->setView('Items/list_items'); $this->view()->assign(['keyword' => $keyword, 'cat_id' => $cat_id, 'is_hot' => $is_hot, 'promotion' => $promotion, 'page' => $page]); return $this->renderComponent(); }
public function executeDetail() { if (!($post = \Posts::retrieveById($this->request()->get('id')))) { $this->raise404(); } $post->setHits($post->getHits() + 1); $post->save(false); $term = \Terms::retrieveById($post->getTermId()); if (($viewProp = $term->getProperty('post_view')) && $this->view()->checkViewFileExist($this->getTemplatePath() . '/Controller/Post/' . $this->_path . $viewProp->getPropertyValue())) { $this->setView('Post/' . $viewProp->getPropertyValue()); } else { $this->setView('Post/default'); } $this->view()->assign(array('post' => $post, 'term' => $term)); return $this->renderComponent(); }
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); }
<?php require_once './classes/Terms.php'; $t = new Terms(); $list = $t->get_terms_page(); echo $list;
<?php include "system.php"; include_once 'class/Terms.php'; $o = new Terms(); $s = new XoopsSecurity(); $action = $_REQUEST['action']; $isadmin = $xoopsUser->isAdmin(); $uid = $xoopsUser->getVar('uid'); switch ($action) { case "search": //return xml table to grid $wherestring = " WHERE terms_id>0"; $o->showTerms($wherestring); exit; //after return xml shall not run more code. break; case "save": //process submited xml data from grid $o->saveTerms(); break; default: include "menu.php"; $xoTheme->addStylesheet("{$url}/modules/simantz/include/popup.css"); $xoTheme->addScript("{$url}/modules/simantz/include/popup.js"); $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); $xoTheme->addScript("{$url}/modules/simantz/include/nitobi/nitobi.toolkit.js"); $xoTheme->addStylesheet("{$url}/modules/simantz/include/nitobi/nitobi.grid/nitobi.grid.css"); $xoTheme->addScript("{$url}/modules/simantz/include/nitobi/nitobi.grid/nitobi.grid.js"); $xoTheme->addScript("{$url}/modules/simantz/include/firefox3_6fix.js"); $o->showSearchForm();
/** * Save the tags associated to this object into the terms and object_terms tables * * @param Array $tags strings. The tag names to associate to the object * @param Integer $object_id. The id of the object being tagged * @param String $object_type. The name of the type of the object being tagged. Defaults to post * * @return boolean. Whether the associating succeeded or not. true */ public static function save_associations($terms, $object_id, $object_type = 'post') { if (!$terms instanceof Terms) { $terms = Terms::parse($terms, 'Tag', Tags::vocabulary()); } return self::vocabulary()->set_object_terms($object_type, $object_id, $terms); }
public function saveTerms() { $this->log->showLog(2, "Access saveTerms()"); // die; global $xoopsDB, $saveHandler, $createdby, $timestamp, $defaultorganization_id; $tablename = "sim_terms"; $pkey = "terms_id"; $keyword = "Terms"; $controlfieldname = "terms_name"; $insertCount = $saveHandler->ReturnInsertCount(); $this->log->showLog(3, "Start Insert({$insertCount} records)"); if ($insertCount > 0) { $arrfield = array($controlfieldname, "daycount", "description", "isactive", "defaultlevel", "created", "createdby", "updated", "updatedby", "organization_id"); $arrfieldtype = array('%s', '%d', '%s', '%d', '%d', '%s', '%d', '%s', '%d', '%d'); // Yes there are INSERTs to perform... for ($currentRecord = 0; $currentRecord < $insertCount; $currentRecord++) { $arrvalue = array($saveHandler->ReturnInsertField($currentRecord, $controlfieldname), $saveHandler->ReturnInsertField($currentRecord, "daycount"), $saveHandler->ReturnInsertField($currentRecord, "description"), $saveHandler->ReturnInsertField($currentRecord, "isactive"), $saveHandler->ReturnInsertField($currentRecord, "defaultlevel"), $timestamp, $createdby, $timestamp, $createdby, $defaultorganization_id); $controlvalue = $saveHandler->ReturnInsertField($currentRecord, $controlfieldname); $this->InsertRecord($tablename, $arrfield, $arrvalue, $arrfieldtype, $controlvalue, $pkey); // Now we execute this query } } $updateCount = $saveHandler->ReturnUpdateCount(); $this->log->showLog(3, "Start update({$updateCount} records)"); if ($updateCount > 0) { $arrfield = array($controlfieldname, "daycount", "description", "isactive", "defaultlevel", "updated", "updatedby", "isdeleted"); $arrfieldtype = array('%s', '%d', '%s', '%d', '%d', '%s', '%d', '%d'); // Yes there are UPDATEs to perform... for ($currentRecord = 0; $currentRecord < $updateCount; $currentRecord++) { $arrvalue = array($saveHandler->ReturnUpdateField($currentRecord, $controlfieldname), $saveHandler->ReturnUpdateField($currentRecord, "daycount"), $saveHandler->ReturnUpdateField($currentRecord, "description"), $saveHandler->ReturnUpdateField($currentRecord, "isactive"), $saveHandler->ReturnUpdateField($currentRecord, "defaultlevel"), $timestamp, $createdby, $saveHandler->ReturnUpdateField($currentRecord, "isdeleted")); $controlvalue = $saveHandler->ReturnUpdateField($currentRecord, $controlfieldname); $this->UpdateRecord($tablename, $pkey, $saveHandler->ReturnUpdateField($currentRecord), $arrfield, $arrvalue, $arrfieldtype, $controlvalue); } } $ispurge = 0; $deleteCount = $saveHandler->ReturnDeleteCount(); $this->log->showLog(3, "Start delete/purge({$deleteCount} records)"); $classname = "class/{$keyword}.inc.php"; include $classname; $this->log->showLog(3, "Include {$classname} successfully"); $o = new Terms(); $this->log->showLog(3, "Inilialize {$keyword}()"); if ($deleteCount > 0) { for ($currentRecord = 0; $currentRecord < $deleteCount; $currentRecord++) { $record_id = $saveHandler->ReturnDeleteField($currentRecord); $o->fetchTerms($record_id); $controlvalue = $o->terms_name; $isdeleted = $o->isdeleted; if ($o->allowDelete($record_id)) { $this->DeleteRecord($tablename, $pkey, $record_id, $controlvalue, $isdeleted); } else { $this->failfeedback .= "Cannot delete {$keyword}: {$o->terms_name} <br/>"; } } } //$this->failfeedback.="asdasdpasd<br/>\n"; //$this->failfeedback.="123 3443<br/>\n"; //$this->failfeedback.="234 45656523 234<br/>\n"; if ($this->failfeedback != "") { $this->failfeedback .= "Warning!<br/>\n" . $this->failfeedback; } $saveHandler->setErrorMessage($this->failfeedback); $saveHandler->CompleteSave(); }
/** * @param \Menus $menu * @param array $lists * @param $deep */ protected function _getItems($menu, &$lists, $deep) { $deep--; /** @var \Menus[] $child */ $child = $menu->getChildren(); if ($menu->getType() == \Menus::INTERNAL) { $param = json_decode($menu->getRouteParam()); } if (!$child && $deep > 0 && $menu->getType() == \Menus::INTERNAL && $menu->getRoute() == 'category/default' && @$param->fetch_child) { if (@$param->id) { $cat = Terms::retrieveById(@$param->id); if ($cat) { $childCat = $cat->getChildren(); foreach ($childCat as $cc) { $c = new \Menus(); $c->setType(\Menus::INTERNAL); $c->setName($cc->getName()); $c->setRoute('category/default'); $c->setRouteParam('{"id":' . $cc->getId() . '}'); if (!is_array($child)) { $child = array(); } $child[] = $c; } } else { return; } } } if (!$child && $deep > 0 && $menu->getType() == \Menus::INTERNAL && $menu->getRoute() == 'products/category' && @$param->fetch_child) { if (@$param->id) { $cat = Terms::retrieveById(@$param->id); if ($cat) { $childCat = $cat->getChildren(); foreach ($childCat as $cc) { $c = new \Menus(); $c->setType(\Menus::INTERNAL); $c->setName($cc->getName()); $c->setRoute('products/category'); $c->setRouteParam('{"id":' . $cc->getId() . '}'); if (!is_array($child)) { $child = array(); } $child[] = $c; } } else { return; } } } if (!$child || $deep < 0) { return; } if (isset($lists['items'])) { $lists['items'] = array(); } foreach ($child as $c) { if ($c->getType() == \Menus::SEPARATE) { $url = array('#'); } else { if ($c->getType() == \Menus::EXTERNAL) { $url = array($c->getLink()); } else { if ($c->getType() == \Menus::INTERNAL) { $param = $c->getRouteParam() ? json_decode($c->getRouteParam(), true) : array(); $url = array($c->getRoute()); foreach ($param as $k => $v) { $url[$k] = $v; } } } } $_item = array('label' => $c->getName(), 'url' => $url); $this->_getItems($c, $_item, $deep); $lists['items'][] = $_item; } }
/** * Magic __get method for returning property values * Override the handling of the value property to properly return the setting of the checkbox. * * @param string $name The name of the property * @return mixed The value of the requested property */ public function __get( $name ) { static $posted = null; switch ( $name ) { case 'value': if ( isset( $_POST[$this->field . '_submitted'] ) ) { if(!isset($posted)) { $valuesj = $_POST->raw( $this->field . '_submitted'); $values = json_decode($valuesj); $terms = array(); foreach($this->get_default() as $term) { $terms[$term->id] = $term; } foreach($values as $value) { $terms[$value->id]->mptt_left = $value->left; $terms[$value->id]->mptt_right = $value->right; } $terms = new Terms($terms); $posted = $terms->tree_sort(); } return $posted; } else { return $this->get_default(); } } return parent::__get( $name ); }
protected function _columnCategory($item) { /** @var \Posts $item */ $s = ''; if ($item->getTermId()) { $category = \Terms::retrieveById($item->getTermId()); if ($category) { $eLink = Factory::getRouter()->createUrl('category/edit', array('id' => $category->getId(), 'taxonomy' => $category->getTaxonomy())); $s .= '<a href="' . $eLink . '">' . $category->getName() . '</a>'; } } return $s; }
/** * Get Cat * @return bool|Terms */ public function getCat() { if ($this->getCatId()) { return \Terms::retrieveById($this->getCatId()); } return false; }
<?php require_once './classes/Terms.php'; $t = new Terms(); $data = $_POST['data']; $list = $t->save_page_changes($data); echo $list;
public function __construct(&$xpdo) { parent::__construct($xpdo); }
/** * function __set * Overrides QueryRecord __set to implement custom object properties * @param string Name of property to return * @return mixed The requested field value */ public function __set( $name, $value ) { switch ( $name ) { case 'pubdate': case 'updated': case 'modified': if ( !( $value instanceOf HabariDateTime ) ) { $value = HabariDateTime::date_create( $value ); } break; case 'tags': if ( $value instanceof Terms ) { return $this->tags_object = $value; } elseif ( is_array( $value ) ) { return $this->tags_object = new Terms($value); } else { return $this->tags_object = Terms::parse( $value, 'Term', Tags::vocabulary() ); } case 'status': return $this->setstatus( $value ); } return parent::__set( $name, $value ); }
public function executeLoadCustomFieldFrm() { $category_id = $this->request()->post('category_id'); $category = \Terms::retrieveById($category_id); if (!$category) { //error return $this->renderText(''); } $post_id = $this->request()->post('post_id'); //load category custom fields $categoryCfs = \TermCustomFields::findByTermId($category_id); if (empty($categoryCfs)) { return $this->renderText(''); } /** @var \PostCustomFields[] $postCfs */ $postCfs = array(); //load item custom field value if exist if ($post_id) { $_postCfs = \PostCustomFields::findByPostId($post_id); for ($i = 0, $size = sizeof($_postCfs); $i < $size; ++$i) { $postCfs[$_postCfs[$i]->getCfId()] = $_postCfs; } unset($_postCfs); } //end load item custom field value $data = array(); foreach ($categoryCfs as $catCf) { $d = (object) $catCf->toArray(); $d->value = ''; if (isset($postCfs[$catCf->getId()])) { //exist items $i = $postCfs[$catCf->getId()]; switch ($catCf->getFormat()) { case 'NUMBER': $d->value = (double) $i->getNumberValue(); break; case 'BOOL': $d->value = (bool) $i->getBoolValue(); break; case 'DATETIME': $d->value = $i->getDatetimeValue(); break; default: $d->value = $i->getTextValue(); } } $data[] = $d; } $data = Plugin::applyFilters('custom_' . $category->getTaxonomy() . '_cf_form_data', $data); $buf = $this->renderPartial(array('data' => $data)); $buf = Plugin::applyFilters('custom_' . $category->getTaxonomy() . '_cf_form', $buf); return $buf; }
public function begin() { $root = Terms::retrieveRoot($this->taxonomy); $this->terms = $root->getDescendants(); }
/** * @param null $scope * @return Terms */ public static function retrieveRoot($scope = null) { $root = new \Terms(); $root = $root->findRoot($scope); if (!$root) { $root = new \Terms(); $root->scope = $scope; $root->taxonomy = $scope; $root->name = 'Root of ' . $scope; $root->makeRoot(); $root->save(); } return $root; }
public function executeDefault() { if (!($cat = \Terms::retrieveById($this->request()->get('id')))) { $this->raise404(); } $viewProp = $cat->getProperty('cat_view'); if ($viewProp) { $this->setView('Category/' . $viewProp->getPropertyValue()); } else { $this->setView('Category/default'); } $child = $cat->getDescendants(); $q = \Posts::select()->where('`status` = :status AND `is_draft` = 0')->setParameter(':status', 'PUBLISH', \PDO::PARAM_STR); //Filter $catId = array($cat->getId()); foreach ($child as $c) { $catId[] = $c->getId(); } $q->andWhere('`term_id` IN (' . implode(',', $catId) . ')'); //Filter by time $day = $this->request()->get('day'); $month = $this->request()->get('month'); $year = $this->request()->get('year'); if ($day || $month || $year) { if ($day) { $q->andWhere('DAY(`created_time`) = :day')->setParameter(':day', $day, \PDO::PARAM_STR); } if ($month) { $q->andWhere('MONTH(`created_time`) = :month')->setParameter(':month', $month, \PDO::PARAM_STR); } if ($year) { $q->andWhere('YEAR(`created_time`) = :year')->setParameter(':year', $year, \PDO::PARAM_STR); } } //Keyword if ($keyword = $this->request()->get('keyword')) { $q->andWhere('`title` LIKE "%' . $keyword . '%"'); } //Ordering $orderingProp = $cat->getProperty('post_ordering'); if ($orderingProp) { switch ($orderingProp->getPropertyValue()) { case 'created_time': $q->addOrderBy('created_time'); break; case 'ordering': $q->addOrderBy('ordering'); break; case 'modified_time': case 'default': default: $q->addOrderBy('created_time', 'DESC'); break; } } else { $q->addOrderBy('created_time', 'DESC'); } $qCount = clone $q; $total = $qCount->count()->execute(); //Paging $pageSizeProp = $cat->getProperty('page_size'); if ($pageSizeProp) { $page_size = $cat->getProperty('page_size')->getPropertyValue(); if (-1 != $pageSizeProp->getPropertyValue()) { $q->setMaxResults($pageSizeProp->getPropertyValue()); $page = $this->request()->get('page', 'INT', 1); $q->setFirstResult(($page - 1) * $pageSizeProp->getPropertyValue()); } } else { $page_size = 25; $q->setMaxResults(25); $page = $this->request()->get('page', 'INT', 1); $q->setFirstResult(($page - 1) * $page_size); } $posts = $q->execute(); $this->view()->assign(array('page_size' => $page_size, 'total' => $total, 'cat' => $cat, 'child' => $child, 'posts' => $posts)); return $this->renderComponent(); }
public function executeCustomField() { $term = \Terms::retrieveById($this->request()->get('id')); $this->setView('custom_fields'); $session = Session::getInstance(); if (!$term) { $session->setFlash('term_message', t('Term not found with' . $this->request()->get('id'))); $this->redirect($this->createUrl('category', array('taxonomy' => $this->request()->get('taxonomy')))); } $error = array(); $message = array(); $input = new \TermCustomFields(); if ($this->request()->isPostRequest()) { $input->hydrate($this->request()->post('custom_fields')); $input->setTermId($term->getId()); if (!($acceptValues = $this->request()->post('accept_values'))) { $acceptValues = explode("\n", $acceptValues); $input->setAcceptValue(json_encode($acceptValues)); } if ($input->save()) { $message = t('Save new custom fields success!'); } else { if (!$input->isValid()) { foreach ($input->getValidationFailures() as $validationFailures) { $error[$validationFailures->getColumn()] = $validationFailures->getMessage(); } } } } $customFields = \TermCustomFields::findByTermId($term->getId()); $this->setView('custom_fields'); $this->view()->assign(array('error' => $error, 'message' => $message, 'term' => $term, 'input' => $input, 'custom_fields' => $customFields)); return $this->renderComponent(); }
/** * Process categories when the publish form is received * **/ public function action_publish_post($post, $form) { if ($post->content_type == Post::type(self::$content_type)) { $categories = array(); // $categories = $this->parse_categories( $form->categories->value ); $categories = Terms::parse($form->categories->value, 'Term', $this->vocabulary); $this->vocabulary->set_object_terms('post', $post->id, $categories); } }
<?php // include_once ('../../mainfile.php'); // include_once (XOOPS_ROOT_PATH.'/header.php'); include "system.php"; include "menu.php"; include "class/nitobi.xml.php"; include "class/Terms.inc.php"; $terms = new Terms(); $xoTheme->addScript('browse.php?Frameworks/jquery/jquery.js'); $terms->showSearchForm(); if ($havewriteperm == 1) { $permctrl = " rowinsertenabled=\"true\" rowdeleteenabled=\"true\" toolbarenabled=\"true\" "; } else { $permctrl = " rowinsertenabled=\"false\" autosaveenabled=\"false\" rowdeleteenabled=\"false\" toolbarenabled=\"false\" "; } echo <<<EOF <link rel="stylesheet" href="include/nitobi/nitobi.grid/nitobi.grid.css" type="text/css" /> <script type="text/javascript" src="include/nitobi/nitobi.toolkit.js"></script> <script type="text/javascript" src="include/nitobi/nitobi.grid/nitobi.grid.js"></script> <script type="text/javascript" src="include/firefox3_6fix.js"></script> <script language="javascript" type="text/javascript"> jQuery(document).ready((function (){nitobi.loadComponent('DataboundGrid');})); function init(){} function search(){ var grid = nitobi.getGrid("DataboundGrid"); var searchterms_name=document.getElementById("searchterms_name").value;
public function process() { $values = json_decode($_POST->raw($this->input_name())); $terms = array(); foreach ($this->value as $term) { $terms[$term->id] = $term; } foreach ($values as $value) { $terms[$value->id]->mptt_left = $value->left; $terms[$value->id]->mptt_right = $value->right; } $terms = new Terms($terms); $posted = $terms->tree_sort(); //$this->set_value($_POST[$this->input_name()], false); $this->set_value($posted, false); }