Пример #1
0
 /**
  * @param $db
  * @param $doTable
  * @param $table
  * @return null|string
  */
 public function setTitle($db, $doTable, $table)
 {
     // sorted by priority
     if (!$doTable) {
         return null;
     }
     $colsForTitle = $this->modules[$doTable]['title'];
     array_unshift($colsForTitle, 'ps_title');
     $colsForTitle = $colsForTitle ? $colsForTitle : array();
     // hook for custom title
     if ($this->modules[$doTable] && is_array($this->modules[$doTable]['setCustomTitle'])) {
         foreach ($this->modules[$doTable]['setCustomTitle'] as $callable) {
             $this->import($callable[0]);
             return $this->{$callable[0]}->{$callable[1]}($table, $db, $colsForTitle, $doTable);
         }
     }
     foreach ($colsForTitle as $title) {
         if (!$db[$title]) {
             continue;
         }
         $ct = deserialize($db[$title]);
         // check if value is serialize
         if (is_array($ct) && !empty($ct)) {
             $meta = Helper::parseStrForMeta($db[$title]);
             $db[$title] = $meta;
         }
         if ($db[$title] && (is_string($db[$title]) || is_numeric($db[$title]))) {
             $return = $db[$title];
             $return = Controller::replaceInsertTags($return);
             $return = strip_tags($return);
             $return = trim($return);
             return $return;
             break;
         }
     }
     return null;
 }