/** * Create form for adding or updating additional field * @param int $structure_id Current structure identifier * @param null $field_id Current field identifier * * @return array Ajax response */ public function __async_form($structure_id, $field_id = null) { /** @var array $return Ajax response array */ $return = array('status' => 0, 'html' => ''); // If exists current structure if (ifcmsnav($structure_id, $cmsNav, 'id')) { // Set default field type $type = 0; // Add structure to view m()->set($cmsNav); } // If exists current field if (dbQuery('field')->id($field_id)->first($cmsField)) { // Get type of field $type = $cmsField->Type; // Add field to view m()->set($cmsField); } // Set Ajax status 1 $return['status'] = 1; // Add select form to view m()->type_select(CMSField::createSelect($type)); // Create view $html = m()->view('form/form')->output(); $return['html'] = $html; // Return Ajax response return $return; }
/** * Set parent structure element to work when building catalog tree * @param mixed $name Pointer to structure object or its name for searching/creating * @return \samson\parse\Excel2 Chaining */ public function setStructure($name) { // If passed parent structure does not exists if (!ifcmsnav($name, $cmsnav, 'Name')) { // Create structure $cmsnav = new \samson\cms\cmsnav(false); $cmsnav->Name = $name; $cmsnav->Url = utf8_translit($name); $cmsnav->Active = 1; $cmsnav->Created = date('Y-m-d h:i:s'); $cmsnav->UserID = self::$user->id; $cmsnav->save(); } // Store pointer to parent structure $this->parent_structure =& $cmsnav; return $this; }