/** * 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; }
/** * 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); } } }
/** * Get material by url * @param $url * @return mixed */ public function getMaterialByUrl($url) { return $this->query->className('samson\\cms\\CMSMaterial')->Url($url)->first(); }
/** * 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(); }
/** * 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(); }