Handles the glossary items
Inheritance: extends Controller
Beispiel #1
0
 /**
  * Loads a list of static routes for the specicifies parameters, returns an array of Staticroute elements
  *
  * @return array
  */
 public function load()
 {
     $glossarysData = $this->db->fetchCol("SELECT id FROM glossary" . $this->getCondition() . $this->getOrder() . $this->getOffsetLimit(), $this->model->getConditionVariables());
     $glossary = array();
     foreach ($glossarysData as $glossaryData) {
         $glossary[] = Glossary::getById($glossaryData);
     }
     $this->model->setGlossary($glossary);
     return $glossary;
 }
Beispiel #2
0
 /**
  * Initialize the class
  *
  * @since     1.0.0
  */
 public function __construct()
 {
     $plugin = Glossary::get_instance();
     $this->cpts = $plugin->get_cpts();
     /*
      * CMB 2 for metabox and many other cool things!
      * https://github.com/WebDevStudios/CMB2
      */
     require_once plugin_dir_path(__FILE__) . '/CMB2/init.php';
     require_once plugin_dir_path(__FILE__) . '/cmb2-extra.php';
     require_once plugin_dir_path(__FILE__) . '/cmb2-post-search-field.php';
     add_filter('multicheck_posttype_posttypes', array($this, 'hide_glossary'));
     /*
      * Add metabox
      */
     add_action('cmb2_init', array($this, 'cmb_glossary'));
 }
 /**
  *
  * @param array $items 
  */
 public function add($items)
 {
     $this->objects_imported = 0;
     $this->objects_skipped = 0;
     foreach ($items as $item) {
         $name = $item->name;
         $description = $item->description;
         if (empty($name) || empty($description)) {
             $this->objects_skipped++;
             continue;
         }
         $item->c_id = $this->course->c_id;
         $item->session_id = $this->course->session_id;
         $repo = Glossary::repository();
         $success = $repo->save($item);
         if ($success) {
             $this->objects_imported++;
         } else {
             $this->objects_skipped++;
         }
     }
 }
Beispiel #4
0
 /**
  * @see ModuleFrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     $glossaries = Glossary::getGlossaries($this->context->language->id, array(), null, null, 'name', 'ASC', true);
     if (Configuration::get('LXK_PAGINATION')) {
         $this->pagination(count($glossaries));
     }
     $alphabets = $this->getAlphabets($glossaries);
     $criteria = array();
     if (Tools::getValue('k')) {
         $criteria['k'] = Tools::getValue('k');
     } elseif (count($alphabets['alphabet'])) {
         $criteria['k'] = $alphabets['alphabet'][0];
     }
     if (Configuration::get('LXK_PAGINATION')) {
         $filtered_list = Glossary::getGlossaries($this->context->language->id, $criteria, null, null, null, null, true);
     } else {
         $filtered_list = $alphabets['glossaries'];
     }
     $this->context->smarty->assign(array('title' => Configuration::get('LXK_PAGE_TITLE'), 'current' => isset($criteria['k']) ? $criteria['k'] : null, 'alphabet' => $alphabets['alphabet'], 'glossaries' => $glossaries, 'filtered_list' => $filtered_list, 'pagination_templates' => dirname(__FILE__) . '/../../views/templates/front/pagination.tpl', 'pagination' => Configuration::get('LXK_PAGINATION')));
     $this->setTemplate('lexipage.tpl');
 }
 /**
  * Initialize the plugin by loading admin scripts & styles and adding a
  * settings page and menu.
  *
  * @since     1.0.0
  */
 private function __construct()
 {
     $plugin = Glossary::get_instance();
     $this->cpts = $plugin->get_cpts();
     // Load admin style sheet and JavaScript.
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_styles'));
     add_action('admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'));
     // Load admin style in dashboard for the At glance widget
     add_action('admin_head-index.php', array($this, 'enqueue_admin_styles'));
     // At Glance Dashboard widget for your cpts
     add_filter('dashboard_glance_items', array($this, 'cpt_glance_dashboard_support'), 10, 1);
     // Activity Dashboard widget for your cpts
     add_filter('dashboard_recent_posts_query_args', array($this, 'cpt_activity_dashboard_support'), 10, 1);
     // Add the options page and menu item.
     add_action('admin_menu', array($this, 'add_plugin_admin_menu'));
     // Add an action link pointing to the options page.
     $plugin_basename = plugin_basename(plugin_dir_path(realpath(dirname(__FILE__))) . GT_SETTINGS . '.php');
     add_filter('plugin_action_links_' . $plugin_basename, array($this, 'add_action_links'));
     /*
      * Import Export settings
      */
     require_once plugin_dir_path(__FILE__) . 'includes/GT_ImpExp.php';
     require_once plugin_dir_path(__FILE__) . 'includes/GT_CMB.php';
 }
 public function glossaryAction()
 {
     if ($this->_getParam("data")) {
         if ($this->getUser()->isAllowed("glossary")) {
             Pimcore_Model_Cache::clearTag("glossary");
             if ($this->_getParam("xaction") == "destroy") {
                 $id = Zend_Json::decode($this->_getParam("data"));
                 $glossary = Glossary::getById($id);
                 $glossary->delete();
                 $this->_helper->json(array("success" => true, "data" => array()));
             } else {
                 if ($this->_getParam("xaction") == "update") {
                     $data = Zend_Json::decode($this->_getParam("data"));
                     // save glossary
                     $glossary = Glossary::getById($data["id"]);
                     if ($data["link"]) {
                         if ($doc = Document::getByPath($data["link"])) {
                             $tmpLink = $data["link"];
                             $data["link"] = $doc->getId();
                         }
                     }
                     $glossary->setValues($data);
                     $glossary->save();
                     if ($link = $glossary->getLink()) {
                         if (intval($link) > 0) {
                             if ($doc = Document::getById(intval($link))) {
                                 $glossary->setLink($doc->getFullPath());
                             }
                         }
                     }
                     $this->_helper->json(array("data" => $glossary, "success" => true));
                 } else {
                     if ($this->_getParam("xaction") == "create") {
                         $data = Zend_Json::decode($this->_getParam("data"));
                         unset($data["id"]);
                         // save glossary
                         $glossary = new Glossary();
                         if ($data["link"]) {
                             if ($doc = Document::getByPath($data["link"])) {
                                 $tmpLink = $data["link"];
                                 $data["link"] = $doc->getId();
                             }
                         }
                         $glossary->setValues($data);
                         $glossary->save();
                         if ($link = $glossary->getLink()) {
                             if (intval($link) > 0) {
                                 if ($doc = Document::getById(intval($link))) {
                                     $glossary->setLink($doc->getFullPath());
                                 }
                             }
                         }
                         $this->_helper->json(array("data" => $glossary, "success" => true));
                     }
                 }
             }
         } else {
             Logger::err("user [" . $this->getUser()->getId() . "] attempted to modify static routes, but has no permission to do so.");
         }
     } else {
         // get list of routes
         $list = new Glossary_List();
         $list->setLimit($this->_getParam("limit"));
         $list->setOffset($this->_getParam("start"));
         if ($this->_getParam("sort")) {
             $list->setOrderKey($this->_getParam("sort"));
             $list->setOrder($this->_getParam("dir"));
         }
         if ($this->_getParam("filter")) {
             $list->setCondition("`text` LIKE " . $list->quote("%" . $this->_getParam("filter") . "%"));
         }
         $list->load();
         $glossaries = array();
         foreach ($list->getGlossary() as $glossary) {
             if ($link = $glossary->getLink()) {
                 if (intval($link) > 0) {
                     if ($doc = Document::getById(intval($link))) {
                         $glossary->setLink($doc->getFullPath());
                     }
                 }
             }
             $glossaries[] = $glossary;
         }
         $this->_helper->json(array("data" => $glossaries, "success" => true, "total" => $list->getTotalCount()));
     }
     $this->_helper->json(false);
 }
Beispiel #7
0
 /**
  * Return an instance of this class.
  *
  * @since     1.0.0
  *
  * @return    object    A single instance of this class.
  */
 public static function get_instance()
 {
     // If the single instance hasn't been set, set it now.
     if (null == self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Glossary $value A Glossary object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Glossary $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getGlossaryId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }