Example #1
0
 /**
  * @author italiano
  * @date 12.12.2014
  * return result localExt function
  */
 private function _getLocalExt($string = null)
 {
     $string = trim($string);
     $content = '';
     $data = array();
     if (isset($string)) {
         $data = explode(' ', $string);
     }
     $class = $args = null;
     foreach ($data as $value) {
         list($type, $attr) = explode('=', $value);
         $attr = trim(str_replace('"', '', $attr));
         $type = trim($type);
         switch ($type) {
             case "class":
                 $class = $attr;
                 break;
             case "params":
                 $args = explode(',', $attr);
                 break;
         }
     }
     if (file_exists(LOCAL_PATH . 'application/localExt/' . $class . '/index.php')) {
         if (isset($args)) {
             VBox::set($class, new $class($args));
         } else {
             VBox::set($class, new $class());
         }
         $content = VBox::get($class)->getResult();
         return $content;
         VBox::clear($class);
     }
     return '';
 }
 public function prepareData()
 {
     $index = -1;
     $blocks2pagesId = 0;
     foreach ($this->blocksData as $row) {
         // Проверяем новый ли блок, если новый то инкерементим индекс
         if ($blocks2pagesId != $row['bp_id']) {
             $blocks2pagesId = $row['bp_id'];
             $index++;
         }
         // Проходим по массиву и ищем в нём дочерние блоки по отношинию к
         // текущему блоку, если есть таковой то добовляем их имена файлов
         // в данные текущего блока
         foreach ($this->blocksData as $tmpRow) {
             if ($row['bp_id'] == $tmpRow['bp_parent']) {
                 $this->blocks[$index]['files_to_include'][$tmpRow['bp_id']] = $tmpRow['b_file'];
             }
         }
         if ($row['bd_hidden'] != 1) {
             // Инициализация смартевских переменных
             switch ($row['bf_type']) {
                 case 'S':
                     // String
                     $this->blocks[$index][$row['bf_name']] = $row['bd_value'];
                     break;
                 case 'A':
                     // Array
                 // Array
                 case 'I':
                     // Image
                 // Image
                 case 'W':
                     // Flash
                     if (strlen($row['bd_value'])) {
                         $this->blocks[$index][$row['bf_name']] = unserialize($row['bd_value']);
                     }
                     break;
                 case 'G':
                     // Gloabal Extension
                     $row['bd_value'] = trim($row['bd_value']);
                     $funcData = array();
                     if (strlen($row['bd_value'])) {
                         $funcData = explode('|', $row['bd_value']);
                     }
                     $defData = explode('|', $row['bf_default']);
                     $func = $defData[0];
                     $extName = $defData[1];
                     $args = array();
                     for ($i = 0; $i < count($funcData); $i++) {
                         $argData = explode(':', $funcData[$i]);
                         switch ($argData[0]) {
                             case 'n':
                                 // variable Name
                                 $args[] = ${$argData}[1];
                                 break;
                             case 'v':
                                 // variable Value
                                 $args[] = $argData[1];
                                 break;
                         }
                     }
                     if (!VBox::isExist($extName)) {
                         VBox::set($extName, new $extName());
                     }
                     if (empty($args)) {
                         $this->blocks[$index][$row['bf_name']] = VBox::get($extName)->{$func}();
                     } else {
                         $this->blocks[$index][$row['bf_name']] = VBox::get($extName)->{$func}($args);
                     }
                     VBox::clear($extName);
                     break;
                 case 'E':
                     // Extension
                     if (isset($this->extensions[$row['bf_name']])) {
                         $extName = $row['bf_name'];
                         $row['bd_value'] = trim($row['bd_value']);
                         if (!empty($row['bd_value'])) {
                             $funcData = explode('|', $row['bd_value']);
                             $args = array();
                             for ($i = 0; $i < count($funcData); $i++) {
                                 $argData = explode(':', $funcData[$i]);
                                 switch ($argData[0]) {
                                     case 'n':
                                         // variable Name
                                         $args[] = ${$argData}[1];
                                         break;
                                     case 'v':
                                         // variable Value
                                         $args[] = $argData[1];
                                         break;
                                 }
                             }
                         }
                         //if(!VBox::isExist($extName)) {
                         if (empty($args)) {
                             VBox::set($extName, new $extName());
                         } else {
                             VBox::set($extName, new $extName($args));
                         }
                         //}
                         $this->blocks[$index][$row['bf_name']] = VBox::get($extName)->getResult();
                         VBox::clear($extName);
                     }
                     break;
                 case 'J':
                     // Json Array
                     if (strlen($row['bd_value'])) {
                         $this->blocks[$index][$row['bf_name']] = json_encode(unserialize($row['bd_value']));
                     }
                     break;
                 case 'L':
                     // select
                     if (strlen($row['bd_value'])) {
                         /* italiano 13.02.2015 */
                         $val = unserialize($row['bd_value']);
                         if (is_array($val) && count($val) == 1) {
                             $this->blocks[$index][$row['bf_name']] = key($val);
                             $this->blocks[$index][$row['bf_name'] . '_val'] = current($val);
                         } else {
                             $this->blocks[$index][$row['bf_name']] = $val;
                         }
                         /* end */
                     }
                     break;
             }
             /* italiano, 04.03.2015 */
             if (defined('WWW2') && WWW2) {
                 $this->blocks[$index]['edit_params']['block'] = $row['b_name'];
                 $this->blocks[$index]['edit_params']['file'] = $row['b_file'];
                 if (isset($row['bf_type']) && !empty($row['bf_type'])) {
                     if ($row['bf_type'] == "L" || $row['bf_type'] == "I" || $row['bf_type'] == "A" || $row['bf_type'] == "W") {
                         $value = array();
                         $value = unserialize($row['bd_value']);
                     } else {
                         $value = '';
                         $value = $row['bd_value'];
                     }
                     $this->blocks[$index]['edit_params']['fields'][] = array('type' => $row['bf_type'], 'id' => $row['bd_id'], 'name' => $row['bf_name'], 'fsid' => $row['bd_bp_id'], 'value' => $value, 'default' => $row['bf_default']);
                 }
             }
             /* [end]*/
         }
         // if hidden field
     }
     $this->prepared = TRUE;
 }