new \Where(\Where::_operator(Gallery::$ACCOUNT,'=',UID)) ]); } static function getMyFaq(){ return Faq::getNameList([ \Query::WHERE => new \Where(\Where::_operator(Faq::$ACCOUNT,'=',UID)) ]); } static function getMyBlog(){ return Blog::getNameList([ \Query::WHERE => new \Where(\Where::_operator(Blog::$ACCOUNT,'=',UID)) ]); } static function getStructure($template_id){ $type = ePageBlockType::getFullArray()[$template_id][pageBlockType::TYPE]; if($type) { switch ($type) { case self::ONE_IMAGE: return [ 'image' => [ pageBlockType::DATA_NAME => 'Картинка', ], ]; case self::ONE_BLOG: return [ 'blog' => [ pageBlockType::DATA_NAME => 'Блог', ], ]; case self::ONE_CONTENT: return [ 'content' => [ pageBlockType::DATA_NAME => 'Контент', ], ]; case self::ONE_TEXT: return [ 'text' => [ pageBlockType::DATA_NAME => 'Текст', ], ]; case self::ONE_GALLERY: return [ 'gallery' => [ pageBlockType::DATA_NAME => 'Галерея', pageBlockType::DATA_CONTROLLER => 'common\gallery', ], ]; case self::ONE_FAQ: return [ 'faq' => [ pageBlockType::DATA_NAME => 'Вопрос-ответ', ], ]; case self::TITLE_CONTENT: return [ 'title' => [ pageBlockType::DATA_NAME => 'Заголовок', ], 'content' => [ pageBlockType::DATA_NAME => 'Контент', ], ]; } } else { if($template_id==ePageBlockType::ARZUMANOV_MAP){ $map = self::arzumanov_map_json(); $res['title'] = [pageBlockType::DATA_NAME=> '']; foreach ($map as $v){ $id = $v['id']; $res[$id.'_vis'] = [pageBlockType::DATA_NAME=> '']; $res[$id.'_title'] = [pageBlockType::DATA_NAME=> '']; $res[$id.'_text'] = [pageBlockType::DATA_NAME=> '']; } return $res; } else { return ePageBlockType::getFullArray()[$template_id][pageBlockType::DATA]; } } } // Общая функция генерация формы static function getForm($block_id,$template,$data){ $res = []; $type = ePageBlockType::getFullArray()[$template][pageBlockType::TYPE]; $structure = self::getStructure($template); if($type){ switch ($type){ case self::ONE_CONTENT: $res = self::one_content($structure,$data); break; case self::ONE_TEXT: $res = self::one_text($structure,$data); break; case self::ONE_GALLERY: $res = self::one_gallery($structure,$data); break; case self::ONE_FAQ: $res = self::one_faq($structure,$data); break; case self::ONE_BLOG: $res = self::one_blog($structure,$data); break; case self::ONE_IMAGE: $res = self::one_image($structure,$data); break; case self::TITLE_CONTENT: $res = self::title_content($structure,$data); break; } } else { switch (intval($template)) { // Нестандартные поля case ePageBlockType::ARZUMANOV_FORM: $res = self::arzumanov_form($structure, $data); break; case ePageBlockType::ARZUMANOV_MAIN_SERVICES: $res = self::arzumanov_main_services($structure, $data); break; case ePageBlockType::ARZUMANOV_PRICE: $res = self::arzumanov_price($structure, $data); break; case ePageBlockType::ARZUMANOV_NUM_LIST_WITH_IMAGE: case ePageBlockType::ARZUMANOV_LIST_WITH_IMAGE: case ePageBlockType::ARZUMANOV_GUARANTEE: $res = self::arzumanov_guarantee($structure, $data); break; case ePageBlockType::ARZUMANOV_MAP: $res = self::arzumanov_map($structure, $data); break; case ePageBlockType::MERAKOM_PROJECT: $res = self::merakom_project($structure, $data); break; case ePageBlockType::ARZUMANOV_REVIEWSS2: $res = self::arzumanov_reviews($structure, $data); break; case ePageBlockType::YANDEX_TURBO_IMAGE: $res = self::ya_turbo_image($structure, $data); break; } } $res[] = [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW => Form::INPUT, Form::TYPE => eInputType::HIDDEN, Form::INPUT_OPT => [ Input::NAME=>'controller', Input::VALUE=> Block::$controller, ] ], [ Form::VIEW => Form::INPUT, Form::TYPE => eInputType::HIDDEN, Form::KEY_VALUE => Block::$ID, Form::INPUT_OPT => [Input::VALUE=>$block_id], ], [ Form::VIEW => Form::INPUT, Form::TYPE => eInputType::HIDDEN, Form::KEY_VALUE => 'save_just_data', Form::INPUT_OPT => [Input::VALUE=>1], ], ] ]; $res[] = [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'', Form::TYPE =>eInputType::SUBMIT, Form::INPUT_OPT => [ Input::CSS_CLASS => MS::CSS_BTN_SAVE, Input::LABEL => $c = V::get(msLang::$BUTTON_SUBMIT), ], ], ], ]; return $res; } static function one_content($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'content', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['content'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ] ]; } static function one_text($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'text', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['text'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ] ]; } static function one_gallery($structure,$data){ $galleries = self::getMyGalleries(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'gallery', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['gallery'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $galleries, Input::VALUE => intval($data['gallery']), ], ], ], ] ]; } static function one_image($structure,$data){ $blog = self::getMyBlog(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::IMAGE, Form::KEY_VALUE =>'image', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['image'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::VALUE => intval($data['image']), Input::SRC => ($c = intval($data['image'])) ? Image::imageResize(Image::getByID($c)[Image::$URL],600,0,100) : '', ], ], ], ] ]; } static function one_blog($structure,$data){ $blog = self::getMyBlog(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'blog', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['blog'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $blog, Input::VALUE => intval($data['blog']), ], ], ], ] ]; } static function one_faq($structure,$data){ $faq = self::getMyFaq(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'faq', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['faq'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $faq, Input::VALUE => intval($data['faq']), ], ], ], ] ]; } static function title_content($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'content', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['content'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ] ]; } // частные случаи форм static function arzumanov_form($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'name', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['name'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'phone', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['phone'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'email', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['email'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'comment', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['comment'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'confidential', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['confidential'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], ]; } static function arzumanov_main_services($structure,$data){ $galleries = self::getMyGalleries(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'gallery', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['gallery'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $galleries, Input::VALUE => intval($data['gallery']), ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'buttons', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['buttons'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ] ]; } static function arzumanov_price($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'price', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['price'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'button', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['button'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'list', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['list'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ] ] ]; } static function arzumanov_map_json(){ $map = file_get_contents(dirname(__FILE__)."/arzumanov_map.json"); return json_decode($map,true); } static function arzumanov_map($structure,$data){ $map = self::arzumanov_map_json(); //$rows = array_chunk($map,ceil(count($map)/3)); $rows = array_chunk($map,3); $res = [[ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c-1-3', Form::TYPE => eInputType::TEXT, Form::KEY_VALUE => 'title', Form::INPUT_OPT => [ Input::LABEL => $c = 'Название карты', Input::PLACEHOLDER => $c, ], ] ] ]]; foreach ($rows as $row) { $row1 = [ Form::VIEW => Form::ROW, Form::COLS => [] ]; $row2 = [ Form::VIEW => Form::ROW, Form::COLS => [] ]; $row3 = [ Form::VIEW => Form::ROW, Form::COLS => [] ]; foreach ($row as $v) { $id = $v['id']; $name = $v['name']; $vis_key = $id.'_vis'; $name_key = $id.'_title'; $text_key = $id.'_text'; $row1[Form::COLS][] = [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c-1-3', Form::TYPE => eInputType::SWITCH_IOS, Form::KEY_VALUE => $vis_key, Form::INPUT_OPT => [ Input::LABEL => ' ', Input::PLACEHOLDER => $name, Input::CHECKED => boolval($data[$vis_key]) ], ]; $row2[Form::COLS][] = [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c-1-3', Form::TYPE => eInputType::TEXT, Form::KEY_VALUE => $name_key, Form::INPUT_OPT => [ Input::LABEL => $c = 'Название', Input::PLACEHOLDER => $c, ], ]; $row3[Form::COLS][] = [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c-1-3', Form::TYPE => eInputType::TEXTAREA, Form::KEY_VALUE => $text_key, Form::INPUT_OPT => [ Input::LABEL => $c = 'Описание', Input::PLACEHOLDER => $c, ], ]; } $res[] = $row1; $res[] = $row2; $res[] = $row3; } return $res; } static function ya_turbo_image($structure,$data) { return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::IMAGE, Form::KEY_VALUE =>'image', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['image'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::SRC => ($c = $data['image']) ? Image::imageResize(Image::getByID($c)[Image::$URL],600,0,100) : '', ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ] ]; } static function arzumanov_reviews($structure,$data) { $galleries = self::getMyGalleries(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c c-1-3', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c c-1-3', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'gallery', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['gallery'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $galleries, Input::VALUE => intval($data['gallery']), ], ], [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c c-1-3', Form::TYPE => eInputType::SWITCH_IOS, Form::KEY_VALUE => 'active', Form::INPUT_OPT => [ Input::LABEL => ' ', Input::PLACEHOLDER => $structure['active'][pageBlockType::DATA_NAME], Input::CHECKED => boolval($data['active']) ], ], [ Form::VIEW => Form::INPUT, Form::COL_CLASSES => 'c c-100', Form::TYPE => eInputType::TEXTAREA, Form::KEY_VALUE => 'text', Form::INPUT_OPT => [ Input::LABEL => $structure['text'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $structure['text'][pageBlockType::DATA_NAME], Input::VALUE => $data['text'], ], ] ], ] ]; } static function arzumanov_guarantee($structure,$data){ return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::IMAGE, Form::KEY_VALUE =>'image', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::SRC => ($c = $data['image']) ? Image::imageResize(Image::getByID($c)[Image::$URL],600,0,100) : '', ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXT, Form::KEY_VALUE =>'title', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['title'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'text', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['text'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ] ] ]; } static function merakom_project($structure,$data){ $galleries = self::getMyGalleries(); return [ [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-1-3', Form::TYPE =>eInputType::SELECT_SEARCH, Form::KEY_VALUE =>'gallery', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['gallery'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, Input::OPTIONS => $galleries, ], ], ], ], [ Form::VIEW => Form::ROW, Form::COLS => [ [ Form::VIEW =>Form::INPUT, Form::COL_CLASSES =>'c-100', Form::TYPE =>eInputType::TEXTAREA, Form::KEY_VALUE =>'text', Form::INPUT_OPT => [ Input::LABEL => $c = $structure['text'][pageBlockType::DATA_NAME], Input::PLACEHOLDER => $c, ], ], ], ], ]; } }