Ejemplo n.º 1
0
 /**
  * Pager db request handler
  * @param \samson\activerecord\dbQuery $query
  */
 public function dbPagerHandler(&$query)
 {
     // Create count request to count pagination
     $countQuery = clone $query;
     $this->pager->update($countQuery->count());
     // Set current page query limits
     $query->limit($this->pager->start, $this->pager->end);
 }
Ejemplo n.º 2
0
 /** Constructor */
 public function __construct()
 {
     parent::__construct('samson\\cms\\CMSMaterial');
     // Create db request
     $this->cond('Active', 1)->join('samson\\cms\\CMSGallery')->join('user')->join('samson\\cms\\CMSNavMaterial');
     //->own_group_by('material.MaterialID');
 }
Ejemplo n.º 3
0
 /**
  * Universal SamsonCMS table render
  * @return string HTML SamsonCMS table
  */
 public function render(array $db_rows = null, $module = null)
 {
     // Rows HTML
     $rows = '';
     // if no rows data is passed - perform db request
     if (!isset($db_rows)) {
         $db_rows = $this->query->exec();
     }
     // If we have table rows data
     if (is_array($db_rows) && sizeof($db_rows)) {
         // Save quantity of rendering rows
         $this->last_render_count = sizeof($db_rows);
         // Debug info
         $rn = 0;
         $rc = sizeof($db_rows);
         // Iterate db data and perform rendering
         foreach ($db_rows as &$db_row) {
             if ($this->debug) {
                 elapsed('Rendering row ' . $rn++ . ' of ' . $rc . '(#' . $db_row->id . ')');
             }
             $rows .= $this->row($db_row, $this->pager, $module);
             //catch(\Exception $e){ return e('Error rendering row#'.$rn.' of '.$rc.'(#'.$db_row->id.')'); }
         }
     } else {
         $rows .= $this->emptyrow($this->query, $this->pager, $module);
     }
     //elapsed('render pages: '.$this->pager->total);
     // Render table view
     return m($module)->view($this->table_tmpl)->set($this->pager)->rows($rows)->output();
 }
Ejemplo n.º 4
0
 /**
  * Get material by url
  * @param $url
  * @return mixed
  */
 public function getMaterialByUrl($url)
 {
     if (empty($url)) {
         return null;
     }
     // If this material located in cache then return it
     if (isset($this->materialByUrlCache[$url])) {
         return $this->materialByUrlCache[$url];
     }
     $result = $this->query->className('samson\\cms\\CMSMaterial')->cond('Url', $url)->first();
     $this->materialByUrlCache[$url] = $result;
     return $result;
 }
Ejemplo n.º 5
0
Archivo: Core.php Proyecto: onysko/seo
 /**
  * Add dynamic tags into specific material
  * @param $materialId
  * @param $structureId
  */
 public function addDynamicTags($materialId, $structureId)
 {
     $dynamicSchema = new Dynamic();
     if ($structureId == $dynamicSchema->getStructureId()) {
         // If binding material and structure don't exists then create it
         if ($this->query->className('structurematerial')->cond('StructureID', $structureId)->cond('MaterialID', $materialId)->count() == 0) {
             // Create relations
             $sm = new structurematerial(false);
             $sm->StructureID = $structureId;
             $sm->MaterialID = $materialId;
             $sm->save();
             // Add row
             m('material_table')->__async_add($materialId, $structureId);
         }
     }
 }
Ejemplo n.º 6
0
 /**
  * Material query injection
  * @param \samson\activerecord\dbQuery $query Query object
  */
 public function materialsHandlers(&$query)
 {
     $query->join('gallery');
 }
Ejemplo n.º 7
0
 /**
  * Function for joining tables to get some extra data in result set
  *
  * @param dbQuery $query Collection query
  */
 public function joinTables(dbQuery $query)
 {
     $query->join('user')->order_by('Modyfied', 'DESC')->join('structurematerial')->join('structure')->cond('structure.system', 0);
 }
Ejemplo n.º 8
0
 /**
  * Get material by url
  * @param $url
  * @return mixed
  */
 public function getMaterialByUrl($url)
 {
     return $this->query->className('samson\\cms\\CMSMaterial')->Url($url)->first();
 }
Ejemplo n.º 9
0
 /**
  * Get field if exists
  * @param $fieldId
  * @param $structureId
  * @return mixed
  */
 public function isFieldAssigned($fieldId, $structureId)
 {
     return $this->query->className('structurefield')->cond('FieldID', $fieldId)->cond('StructureID', $structureId)->first();
 }
Ejemplo n.º 10
0
 /**
  * Get structure if exists
  * @param $name
  * @param $url
  * @return mixed
  */
 public function isStructureExists($name, $url)
 {
     return $this->query->className('\\samson\\cms\\Navigation')->cond('Name', $name)->cond('Url', $url)->first();
 }