当前位置: 首页>>代码示例>>PHP>>正文


PHP Sobi::DefLang方法代码示例

本文整理汇总了PHP中Sobi::DefLang方法的典型用法代码示例。如果您正苦于以下问题:PHP Sobi::DefLang方法的具体用法?PHP Sobi::DefLang怎么用?PHP Sobi::DefLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sobi的用法示例。


在下文中一共展示了Sobi::DefLang方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parseOrdering

 /**
  */
 protected function parseOrdering()
 {
     $order = Sobi::GetUserState('sections.order', 'order', 'name.asc');
     $ord = $order;
     $dir = 'asc';
     if (strstr($order, '.')) {
         $ord = explode('.', $ord);
         $dir = $ord[1];
         $ord = $ord[0];
     }
     if ($ord == 'position') {
         $ord = 'name';
     }
     if ($ord == 'name') {
         /* @var SPdb $db */
         $db =& SPFactory::db();
         try {
             $db->select('id', 'spdb_language', array('oType' => 'section', 'sKey' => 'name', 'language' => Sobi::Lang()), 'sValue.' . $dir);
             $fields = $db->loadResultArray();
             if (!count($fields) && Sobi::Lang() != Sobi::DefLang()) {
                 $db->select('id', 'spdb_language', array('oType' => 'section', 'sKey' => 'name', 'language' => Sobi::DefLang()), 'sValue.' . $dir);
                 $fields = $db->loadResultArray();
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 500, __LINE__, __FILE__);
             return false;
         }
         if (count($fields)) {
             $fields = implode(',', $fields);
             $ord = "field( id, {$fields} )";
         } else {
             $ord = 'id.' . $dir;
         }
     } else {
         $ord = isset($dir) && strlen($dir) ? $ord . '.' . $dir : $ord;
     }
     SPFactory::user()->setUserState('sections.order', $ord);
     return $ord;
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:41,代码来源:front.php

示例2: saveData

 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     /* @var SPdb $db */
     $db = SPFactory::db();
     $save = $this->verify($entry, $request);
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* collect the needed params */
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['baseData'] = $db->escape(SPConfig::serialize($save));
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         /* Notices:
          * If it was new entry - insert
          * If it was an edit and the field wasn't filled before - insert
          * If it was an edit and the field was filled before - update
          *     " ... " and changes are not autopublish it should be insert of the copy .... but
          * " ... " if a copy already exist it is update again
          * */
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* if it wasn't edited in the default language, we have to try to insert it also for def lang */
     if (Sobi::Lang() != Sobi::DefLang()) {
         $params['lang'] = Sobi::DefLang();
         try {
             $db->insert('spdb_field_data', $params, true, true);
         } catch (SPException $x) {
             Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:66,代码来源:email.php

示例3: save

 public function save(&$attr)
 {
     static $lang = null;
     static $defLang = null;
     if (!$lang) {
         $lang = Sobi::Lang();
         $defLang = Sobi::DefLang();
     }
     $file = SPRequest::file('spfieldsopts', 'tmp_name');
     if ($file) {
         $data = parse_ini_file($file, true);
     } elseif (is_string($attr['options'])) {
         $data = parse_ini_string($attr['options'], true);
     } else {
         $data = null;
     }
     $options = $this->parseOptsFile($data);
     if (!count($options) && count($attr['options'])) {
         $p = 0;
         $hold = array();
         foreach ($attr['options'] as $o) {
             if (is_numeric($o['id'])) {
                 $o['id'] = $this->nid . '_' . $o['id'];
             }
             if (isset($o['id'])) {
                 $i = 0;
                 $oid = $o['id'];
                 while (isset($hold[$oid])) {
                     $oid = $o['id'] . '_' . ++$i;
                 }
                 $options[] = array('id' => $oid, 'name' => $o['name'], 'parent' => null, 'position' => ++$p);
                 $hold[$oid] = $oid;
             }
         }
     }
     if (count($options)) {
         unset($attr['options']);
         $optionsArr = array();
         $labelsArr = array();
         $defLabelsArr = array();
         $optsIds = array();
         foreach ($options as $i => $option) {
             /* check for doubles */
             foreach ($options as $pos => $opt) {
                 if ($i == $pos) {
                     continue;
                 }
                 if ($option['id'] == $opt['id']) {
                     $option['id'] = $option['id'] . '_' . substr((string) microtime(), 2, 8) . rand(1, 100);
                     SPFactory::message()->warning('FIELD_WARN_DUPLICATE_OPT_ID');
                 }
             }
             $optionsArr[] = array('fid' => $this->id, 'optValue' => $option['id'], 'optPos' => $option['position'], 'optParent' => $option['parent']);
             $defLabelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $defLang, 'oType' => 'field_option', 'fid' => $this->id);
             $labelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $lang, 'oType' => 'field_option', 'fid' => $this->id);
             $optsIds[] = $option['id'];
         }
         /* @var SPdb $db */
         $db =& SPFactory::db();
         /* try to delete the existing labels */
         try {
             $db->delete('spdb_field_option', array('fid' => $this->id));
             $db->delete('spdb_language', array('oType' => 'field_option', 'fid' => $this->id, '!sKey' => $optsIds));
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_DELETE_SELECTED_OPTIONS', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
         /* insert new values */
         try {
             $db->insertArray('spdb_field_option', $optionsArr);
             $db->insertArray('spdb_language', $labelsArr, true);
             if ($defLang != $lang) {
                 $db->insertArray('spdb_language', $defLabelsArr, false, true);
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_STORE_FIELD_OPTIONS_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     if (!isset($attr['params'])) {
         $attr['params'] = array();
     }
     $myAttr = $this->getAttr();
     $properties = array();
     if (count($myAttr)) {
         foreach ($myAttr as $property) {
             $properties[$property] = isset($attr[$property]) ? $attr[$property] : null;
         }
     }
     $attr['params'] = $properties;
     $this->sets['field.options'] = SPFactory::Instance('types.array')->toINIString($data);
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:90,代码来源:chbxgroup.php

示例4: sortBy

 /**
  * Static function to create the right SQL-Query if a entries list should be sorted by this field
  * @param string $tables - table or tables join
  * @param array $conditions - array with conditions
  * @param string $oPrefix
  * @param string $eOrder
  * @param string $eDir
  * @return void
  */
 public static function sortBy(&$tables, &$conditions, &$oPrefix, &$eOrder, $eDir)
 {
     /* @var SPdb $db */
     $db =& SPFactory::db();
     $tables = $db->join(array(array('table' => 'spdb_field_option_selected', 'as' => 'sdata', 'key' => 'fid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => array('sdata.sid', 'spo.id')), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => array('fdata.fid', 'sdata.fid')), array('table' => 'spdb_field', 'as' => 'fdef', 'key' => array('fdef.fid', 'sdata.fid')), array('table' => 'spdb_language', 'as' => 'ldata', 'key' => array('sdata.optValue', 'ldata.sKey')), array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => array('spo.id', 'sprl.id'))));
     $oPrefix = 'spo.';
     $conditions['spo.oType'] = 'entry';
     if (!isset($conditions['sprl.pid'])) {
         $conditions['sprl.pid'] = SPRequest::sid();
     }
     $conditions['ldata.oType'] = 'field_option';
     $conditions['fdef.nid'] = $eOrder;
     $eOrder = 'sValue.' . $eDir . ", field( language, '" . Sobi::Lang(false) . "', '" . Sobi::DefLang() . "' )";
     return true;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:24,代码来源:select.php

示例5: save

 public function save(&$attr)
 {
     static $lang = null;
     static $defLang = null;
     if (!$lang) {
         $lang = Sobi::Lang();
         $defLang = Sobi::DefLang();
     }
     $file = SPRequest::file('spfieldsopts', 'tmp_name');
     if ($file) {
         $data = parse_ini_file($file, true);
     } elseif (is_string($attr['options'])) {
         $data = parse_ini_string($attr['options'], true);
     } else {
         $data = null;
     }
     $options = $this->parseOptsFile($data);
     if (!count($options) && count($attr['options'])) {
         $p = 0;
         $hold = array();
         foreach ($attr['options'] as $o) {
             if (is_numeric($o['id'])) {
                 $o['id'] = $this->nid . '_' . $o['id'];
             }
             if (isset($o['id'])) {
                 $i = 0;
                 $oid = $o['id'];
                 while (isset($hold[$oid])) {
                     $oid = $o['id'] . '_' . ++$i;
                 }
                 $options[] = array('id' => $oid, 'name' => $o['name'], 'parent' => null, 'position' => ++$p);
                 $hold[$oid] = $oid;
             }
         }
     }
     if (count($options)) {
         unset($attr['options']);
         $optionsArr = array();
         $labelsArr = array();
         $optsIds = array();
         $defLabelsArr = array();
         $duplicates = false;
         foreach ($options as $i => $option) {
             /* check for doubles */
             foreach ($options as $pos => $opt) {
                 if ($i == $pos) {
                     continue;
                 }
                 if ($option['id'] == $opt['id']) {
                     $option['id'] = $option['id'] . '_' . substr((string) microtime(), 2, 8) . rand(1, 100);
                     $duplicates = true;
                 }
             }
             $optionsArr[] = array('fid' => $this->id, 'optValue' => $option['id'], 'optPos' => $option['position'], 'optParent' => $option['parent']);
             $defLabelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $defLang, 'oType' => 'field_option', 'fid' => $this->id);
             $labelsArr[] = array('sKey' => $option['id'], 'sValue' => $option['name'], 'language' => $lang, 'oType' => 'field_option', 'fid' => $this->id);
             $optsIds[] = $option['id'];
         }
         if ($duplicates) {
             SPFactory::message()->warning('FIELD_WARN_DUPLICATE_OPT_ID');
         }
         $db = SPFactory::db();
         /* try to delete the existing labels */
         try {
             $db->delete('spdb_field_option', array('fid' => $this->id));
             $db->delete('spdb_language', array('oType' => 'field_option', 'fid' => $this->id, '!sKey' => $optsIds));
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_STORE_FIELD_OPTIONS_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
         /* insert new values */
         try {
             $db->insertArray('spdb_field_option', $optionsArr);
             $db->insertArray('spdb_language', $labelsArr, true);
             if ($defLang != $lang) {
                 $db->insertArray('spdb_language', $defLabelsArr, false, true);
             }
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_DELETE_SELECTED_OPTIONS', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     if (!isset($attr['params'])) {
         $attr['params'] = array();
     }
     $myAttr = $this->getAttr();
     $properties = array();
     if (count($myAttr)) {
         foreach ($myAttr as $property) {
             $properties[$property] = isset($attr[$property]) ? $attr[$property] : null;
         }
     }
     $this->sets['field.options'] = SPFactory::Instance('types.array')->toINIString($data);
     /** handle upload of new definition file */
     $XMLFile = SPRequest::file('select-list-dependency', 'tmp_name');
     if ($XMLFile && file_exists($XMLFile)) {
         $XMLFileName = SPRequest::file('select-list-dependency', 'name');
         if (SPFs::getExt($XMLFileName) == 'zip') {
             $arch = SPFactory::Instance('base.fs.archive');
             $name = str_replace('.zip', null, $XMLFileName);
             $path = SPLoader::dirPath('tmp.install.' . $name, 'front', false);
             $c = 0;
//.........这里部分代码省略.........
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:101,代码来源:select.php

示例6: saveNew


//.........这里部分代码省略.........
         $base['notice'] = $db->escape($attr['notice']);
     }
     if (isset($attr['showIn'])) {
         $base['showIn'] = $db->escape(preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['showIn']));
     }
     if (isset($attr['fieldType'])) {
         $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['fieldType']);
     }
     if (isset($attr['type'])) {
         $base['fieldType'] = preg_replace('/[^[:alnum:]\\.\\-\\_]/', null, $attr['type']);
     }
     if (isset($attr['description'])) {
         $base['description'] = $db->escape($attr['description']);
     }
     if (isset($attr['enabled'])) {
         $base['enabled'] = (int) $attr['enabled'];
     }
     if (isset($attr['required'])) {
         $base['required'] = (int) $attr['required'];
     }
     if (isset($attr['adminField'])) {
         $base['adminField'] = (int) $attr['adminField'];
     }
     if (isset($attr['adminField']) && $attr['adminField']) {
         $attr['required'] = false;
     }
     if (isset($attr['editable'])) {
         $base['editable'] = (int) $attr['editable'];
     }
     if (isset($attr['editLimit'])) {
         $base['editLimit'] = (int) $attr['editLimit'];
         $base['editLimit'] = $base['editLimit'] > 0 ? $base['editLimit'] : -1;
     }
     if (isset($attr['isFree'])) {
         $base['isFree'] = (int) $attr['isFree'];
     }
     if (isset($attr['withLabel'])) {
         $base['withLabel'] = (int) $attr['withLabel'];
     }
     if (isset($attr['inSearch'])) {
         $base['inSearch'] = (int) $attr['inSearch'];
     }
     if (isset($attr['admList'])) {
         $base['admList'] = (int) $attr['admList'];
     }
     if (isset($attr['fee'])) {
         $base['fee'] = (double) $attr['fee'];
     }
     if (isset($attr['section'])) {
         $base['section'] = (int) $attr['section'];
     }
     $base['version'] = 1;
     /* determine the right position */
     try {
         $db->select('MAX( position )', 'spdb_field', array('section' => SPRequest::sid()));
         $base['position'] = (int) $db->loadResult() + 1;
         if (!$base['position']) {
             $base['position'] = 1;
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_FIELD_POSITION_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     /* get database columns and their ordering */
     $cols = $db->getColumns('spdb_field');
     $values = array();
     /* and sort the properties in the same order */
     foreach ($cols as $col) {
         $values[$col] = array_key_exists($col, $base) ? $base[$col] : '';
     }
     /* save new field */
     try {
         $db->insert('spdb_field', $values);
         $this->fid = $db->insertid();
     } catch (SPException $x) {
         Sobi::Error($this->name(), $x->getMessage(), SPC::ERROR, 500, __LINE__, __FILE__);
     }
     /* save language depend properties */
     $labels = array();
     $defLabels = array();
     $labels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     $labels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     $labels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::Lang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     if (Sobi::Lang() != Sobi::DefLang()) {
         $defLabels[] = array('sKey' => 'name', 'sValue' => $base['name'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
         $defLabels[] = array('sKey' => 'suffix', 'sValue' => $base['suffix'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
         $defLabels[] = array('sKey' => 'description', 'sValue' => $base['description'], 'language' => Sobi::DefLang(), 'id' => 0, 'oType' => 'field', 'fid' => $this->fid);
     }
     if (count($labels)) {
         try {
             if (Sobi::Lang() != Sobi::DefLang()) {
                 $db->insertArray('spdb_language', $defLabels, false, true);
             }
             $db->insertArray('spdb_language', $labels, true);
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('CANNOT_SAVE_FIELD_DB_ERR', $x->getMessage()), SPC::ERROR, 500, __LINE__, __FILE__);
         }
     }
     SPFactory::cache()->cleanSection();
     return $this->fid;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:101,代码来源:field.php

示例7: translateObject

 /**
  * Translating language depend attributes of objects
  *
  * @param array $sids - array with ids of objects to translate
  * @param array $fields - (optional) array (or string) with properties names to translate. If not given, translates all
  * @param string $type - (optional) type of object (section, category, entry). If not given, translates all
  * @param string $lang - (optional) specific language. If not given, use currently set language
  * @param string $ident
  * @return array
  */
 public static function translateObject($sids, $fields = array(), $type = null, $lang = null, $ident = 'id')
 {
     /** @todo multiple attr does not work because the id is the object id */
     $fields = is_array($fields) ? $fields : (strlen($fields) ? array($fields) : null);
     $lang = $lang ? $lang : Sobi::Lang(false);
     // we don't need to specify the language as we want to have all of them and then order it right
     // when an object name has been entered in a particular language but this language isn't used later
     // we won't have any label for this certain object
     // Wed, Dec 18, 2013 09:57:04
     //$params = array( 'id' => $sids, 'language' => array( $lang, Sobi::DefLang(), 'en-GB' ) );
     $params = array($ident => $sids);
     $result = array();
     if ($type) {
         $params['oType'] = $type;
     }
     if (in_array('alias', $fields)) {
         $fields[] = 'nid';
     }
     if ($fields && count($fields)) {
         $params['sKey'] = $fields;
     }
     try {
         $labels = SPFactory::db()->select($ident . ' AS id, sKey AS label, sValue AS value, language', 'spdb_language', $params, "FIELD( language, '{$lang}', '" . Sobi::DefLang() . "' )")->loadAssocList();
         if (count($labels)) {
             $aliases = array();
             if (in_array('alias', $fields)) {
                 $aliases = SPFactory::db()->select(array('nid', 'id'), 'spdb_object', array('id' => $sids))->loadAssocList('id');
             }
             foreach ($labels as $label) {
                 if ($label['label'] == 'nid') {
                     $result[$label['id']]['alias'] = $label['value'];
                 } else {
                     if (!isset($result[$label['id']]) || $label['language'] == Sobi::Lang()) {
                         $result[$label['id']] = $label;
                     }
                 }
                 if (in_array('nid', $fields)) {
                     if (!isset($result[$label['id']]['alias'])) {
                         $result[$label['id']]['alias'] = isset($aliases[$label['id']]) ? $aliases[$label['id']]['nid'] : null;
                     }
                 }
             }
         }
     } catch (SPError $x) {
         Sobi::Error('language', SPLang::e('CANNOT_TRANSLATE_OBJECT', $x->getMessage()), SPC::WARNING, 500, __LINE__, __CLASS__);
     }
     return $result;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:58,代码来源:lang.php

示例8: parseOrdering

 /**
  * @param string $subject
  * @param string $col
  * @param string $def
  * @param int $lim
  * @param int $lStart
  * @param $sids
  * @return string
  */
 protected function parseOrdering($subject, $col, $def, &$lim, &$lStart, &$sids)
 {
     $ord = Sobi::GetUserState($subject . '.order', $col, Sobi::Cfg('admin.' . $subject . '-order', $def));
     $ord = str_replace(array('e_s', 'c_s'), null, $ord);
     if (strstr($ord, '.')) {
         $ord = explode('.', $ord);
         $dir = $ord[1];
         $ord = $ord[0];
     } else {
         $dir = 'asc';
     }
     if ($ord == 'order' || $ord == 'position') {
         $subject = $subject == 'categories' ? 'category' : 'entry';
         /* @var SPdb $db */
         $db = SPFactory::db();
         $db->select('id', 'spdb_relations', array('oType' => $subject, 'pid' => $this->_model->get('id')), 'position.' . $dir, $lim, $lStart);
         $fields = $db->loadResultArray();
         if (count($fields)) {
             $sids = $fields;
             $fields = implode(',', $fields);
             $ord = "field( id, {$fields} )";
             $lStart = 0;
             $lim = 0;
         } else {
             $ord = 'id.' . $dir;
         }
     } elseif ($ord == 'name') {
         $subject = $subject == 'categories' ? 'category' : 'entry';
         /* @var SPdb $db */
         $db =& SPFactory::db();
         $db->select('id', 'spdb_language', array('oType' => $subject, 'sKey' => 'name', 'language' => Sobi::Lang()), 'sValue.' . $dir);
         $fields = $db->loadResultArray();
         if (!count($fields) && Sobi::Lang() != Sobi::DefLang()) {
             $db->select('id', 'spdb_language', array('oType' => $subject, 'sKey' => 'name', 'language' => Sobi::DefLang()), 'sValue.' . $dir);
             $fields = $db->loadResultArray();
         }
         if (count($fields)) {
             $fields = implode(',', $fields);
             $ord = "field( id, {$fields} )";
         } else {
             $ord = 'id.' . $dir;
         }
     } elseif (strstr($ord, 'field_')) {
         $db = SPFactory::db();
         static $field = null;
         if (!$field) {
             try {
                 $db->select('fieldType', 'spdb_field', array('nid' => $ord, 'section' => Sobi::Section()));
                 $fType = $db->loadResult();
             } catch (SPException $x) {
                 Sobi::Error($this->name(), SPLang::e('CANNOT_DETERMINE_FIELD_TYPE', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
             }
             if ($fType) {
                 $field = SPLoader::loadClass('opt.fields.' . $fType);
             }
         }
         /* *
          * @TODO The whole sort by custom field method in admin panel has to be re-implemented -
          * We could use the same field 'sortBy' method for backend and frontend.
          * The current method could be very inefficient !!!
          */
         if ($field && method_exists($field, 'sortByAdm')) {
             $fields = call_user_func_array(array($field, 'sortByAdm'), array(&$ord, &$dir));
         } else {
             $join = array(array('table' => 'spdb_field', 'as' => 'def', 'key' => 'fid'), array('table' => 'spdb_field_data', 'as' => 'fdata', 'key' => 'fid'));
             $db->select('sid', $db->join($join), array('def.nid' => $ord, 'lang' => Sobi::Lang()), 'baseData.' . $dir);
             $fields = $db->loadResultArray();
         }
         if (count($fields)) {
             $fields = implode(',', $fields);
             $ord = "field( id, {$fields} )";
         } else {
             $ord = 'id.' . $dir;
         }
     } elseif ($ord == 'state') {
         $ord = $ord . '.' . $dir . ', validSince.' . $dir . ', validUntil.' . $dir;
     } else {
         $ord = $ord . '.' . $dir;
     }
     return $ord;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:90,代码来源:section.php

示例9: loadTables

 /**
  */
 private function loadTables()
 {
     try {
         $lang = Sobi::Lang(false);
         $labels = SPFactory::db()->select(array('sValue', 'sKey'), 'spdb_language', array('fid' => $this->id, 'sKey' => $this->_translatable, 'oType' => 'field'), "FIELD( language, '{$lang}', '%' ) ASC")->loadAssocList('sKey');
         if (!count($labels)) {
             // last fallback
             $labels = SPFactory::db()->select(array('sValue', 'sKey'), 'spdb_language', array('fid' => $this->id, 'sKey' => $this->_translatable, 'language' => 'en-GB', 'oType' => 'field'))->loadAssocList('sKey');
         }
         if (Sobi::Lang(false) != Sobi::DefLang()) {
             $labels2 = SPFactory::db()->select(array('sValue', 'sKey'), 'spdb_language', array('fid' => $this->id, 'sKey' => $this->_translatable, 'language' => Sobi::DefLang(), 'oType' => 'field'))->loadAssocList('sKey');
             $labels = array_merge($labels2, $labels);
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     if (count($labels)) {
         Sobi::Trigger('Field', ucfirst(__FUNCTION__), array(&$labels));
         foreach ($labels as $k => $v) {
             $this->_set($k, $v['sValue']);
         }
     }
     $this->priority = $this->priority ? $this->priority : 5;
     /* if field is an admin filed - it cannot be required */
     if (($this->adminField || !$this->editable || !$this->enabled) && !defined('SOBIPRO_ADM')) {
         $this->required = false;
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:30,代码来源:field.php

示例10: saveData

 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     $data = $this->verify($entry, $request);
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* if we are here, we can save these data */
     /* @var SPdb $db */
     $db =& SPFactory::db();
     if ($this->allowHtml) {
         /* filter data */
         if (count($this->allowedAttributes)) {
             SPRequest::setAttributesAllowed($this->allowedAttributes);
         }
         if (count($this->allowedTags)) {
             SPRequest::setTagsAllowed($this->allowedTags);
         }
         $data = SPRequest::string($this->nid, null, $this->allowHtml, $request);
         SPRequest::resetFilter();
         if (!$this->editor && $this->maxLength && strlen($data) > $this->maxLength) {
             $data = substr($data, 0, $this->maxLength);
         }
     } else {
         $data = strip_tags($data);
     }
     /* collect the needed params */
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['params'] = null;
     $params['options'] = null;
     $params['baseData'] = $data;
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* if it wasn't edited in the default language, we have to try to insert it also for def lang */
     if (Sobi::Lang() != Sobi::DefLang()) {
         $params['lang'] = Sobi::DefLang();
         try {
             $db->insert('spdb_field_data', $params, true, true);
         } catch (SPException $x) {
             Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:78,代码来源:textarea.php

示例11: getCats

 /**
  * @param $cOrder
  * @param int $cLim
  * @internal param string $eOrder
  * @internal param int $eLimit
  * @internal param int $eLimStart
  * @return array
  */
 public function getCats($cOrder, $cLim = 0)
 {
     $categories = array();
     $cOrder = trim($cOrder);
     $cLim = $cLim > 0 ? $cLim : 0;
     if ($this->_model->getChilds('category')) {
         /* var SPDb $db */
         $db = SPFactory::db();
         $oPrefix = null;
         /* load needed definitions */
         SPLoader::loadClass('models.dbobject');
         $conditions = array();
         switch ($cOrder) {
             case 'name.asc':
             case 'name.desc':
                 $table = $db->join(array(array('table' => 'spdb_language', 'as' => 'splang', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
                 $oPrefix = 'spo.';
                 $conditions['spo.oType'] = 'category';
                 $conditions['splang.sKey'] = 'name';
                 $conditions['splang.language'] = array(Sobi::Lang(false), Sobi::DefLang(), 'en-GB');
                 if (strstr($cOrder, '.')) {
                     $cOrder = explode('.', $cOrder);
                     $cOrder = 'sValue.' . $cOrder[1];
                 }
                 break;
             case 'position.asc':
             case 'position.desc':
                 $table = $db->join(array(array('table' => 'spdb_relations', 'as' => 'sprl', 'key' => 'id'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
                 $conditions['spo.oType'] = 'category';
                 $oPrefix = 'spo.';
                 break;
             case 'counter.asc':
             case 'counter.desc':
                 $table = $db->join(array(array('table' => 'spdb_counter', 'as' => 'spcounter', 'key' => 'sid'), array('table' => 'spdb_object', 'as' => 'spo', 'key' => 'id')));
                 $oPrefix = 'spo.';
                 $conditions['spo.oType'] = 'category';
                 if (strstr($cOrder, '.')) {
                     $cOrder = explode('.', $cOrder);
                     $cOrder = 'spcounter.counter.' . $cOrder[1];
                 }
                 break;
             default:
                 $table = 'spdb_object';
                 break;
         }
         /* check user permissions for the visibility */
         if (Sobi::My('id')) {
             if (!Sobi::Can('category.access.*')) {
                 if (Sobi::Can('category.access.unapproved_own')) {
                     $conditions[] = $db->argsOr(array('approved' => '1', 'owner' => Sobi::My('id')));
                 } else {
                     $conditions[$oPrefix . 'approved'] = '1';
                 }
             }
             if (!Sobi::Can('category.access.unpublished')) {
                 if (Sobi::Can('category.access.unpublished_own')) {
                     $conditions[] = $db->argsOr(array('state' => '1', 'owner' => Sobi::My('id')));
                 } else {
                     $conditions[$oPrefix . 'state'] = '1';
                 }
             }
             if (!Sobi::Can('category.access.*')) {
                 if (Sobi::Can('category.access.expired_own')) {
                     $conditions[] = $db->argsOr(array('@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince'), 'owner' => Sobi::My('id')));
                 } else {
                     $conditions['state'] = '1';
                     $conditions['@VALID'] = $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince');
                 }
             }
         } else {
             $conditions = array_merge($conditions, array($oPrefix . 'state' => '1', $oPrefix . 'approved' => '1', '@VALID' => $db->valid($oPrefix . 'validUntil', $oPrefix . 'validSince')));
         }
         $conditions[$oPrefix . 'id'] = $this->_model->getChilds('category');
         try {
             $results = $db->select($oPrefix . 'id', $table, $conditions, $cOrder, $cLim, 0, true)->loadResultArray();
         } catch (SPException $x) {
             Sobi::Error($this->name(), SPLang::e('DB_REPORTS_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
         Sobi::Trigger($this->name(), 'AfterGetCategories', array(&$results));
         if ($results && count($results)) {
             foreach ($results as $i => $cid) {
                 $categories[$i] = $cid;
                 // new $cClass();
                 //$categories[ $i ]->init( $cid );
             }
         }
     }
     return $categories;
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:97,代码来源:section.php

示例12: parseOrdering

 /**
  * @param string $col
  * @param string $def
  * @return string
  */
 protected function parseOrdering($col, $def)
 {
     $order = Sobi::GetUserState('fields.order', $col, Sobi::Cfg('admin.fields-order', $def));
     $ord = $order;
     $dir = 'asc';
     /** legacy - why the hell I called it order?! */
     $ord = str_replace('order', 'position', $ord);
     if (strstr($ord, '.')) {
         $ord = explode('.', $ord);
         $dir = $ord[1];
         $ord = $ord[0];
     }
     $ord = $ord == 'state' ? 'enabled' : $ord;
     //		$ord = ( $ord == 'position' ) ? 'position' : $ord;
     if ($ord == 'name') {
         /* @var SPdb $db */
         $db = SPFactory::db();
         $fields = $db->select('fid', 'spdb_language', array('oType' => 'field', 'sKey' => 'name', 'language' => Sobi::Lang()), 'sValue.' . $dir)->loadResultArray();
         if (!count($fields) && Sobi::Lang() != Sobi::DefLang()) {
             $fields = $db->select('id', 'spdb_language', array('oType' => 'field', 'sKey' => 'name', 'language' => Sobi::DefLang()), 'sValue.' . $dir)->loadResultArray();
         }
         if (count($fields)) {
             $fields = implode(',', $fields);
             $ord = "field( fid, {$fields} )";
         } else {
             $ord = 'fid.' . $dir;
         }
     } else {
         $ord = $ord . '.' . $dir;
     }
     Sobi::setUserState('fields.order', $order);
     return $ord;
 }
开发者ID:kishoreweblabs,项目名称:SobiPro,代码行数:38,代码来源:field.php

示例13: searchForm

 /**
  * Shows the field in the search form
  * @param bool $return return or display directly
  * @return string
  */
 public function searchForm($return = false)
 {
     if ($this->searchMethod == 'general') {
         return false;
     }
     if ($this->searchMethod == 'range') {
         return $this->rangeSearch($this->searchRangeValues, $this->freeRange);
     }
     $fdata = array();
     try {
         $data = SPFactory::db()->dselect(array('baseData', 'sid', 'lang'), 'spdb_field_data', array('fid' => $this->fid, 'copy' => '0', 'enabled' => 1), 'field( lang, \'' . Sobi::Lang() . '\'), baseData', 0, 0, 'baseData')->loadAssocList();
         $languages = array();
         $output = array();
         $lang = Sobi::Lang(false);
         $defLang = Sobi::DefLang();
         if (count($data)) {
             foreach ($data as $row) {
                 $languages[$row['lang']][$row['sid']] = $row['baseData'];
             }
         }
         if (isset($languages[$lang])) {
             foreach ($languages[$lang] as $sid => $fieldData) {
                 $output[$sid] = $fieldData;
             }
             unset($languages[$lang]);
         }
         if (isset($languages[$defLang])) {
             foreach ($languages[$defLang] as $sid => $fieldData) {
                 if (!isset($output[$sid])) {
                     $output[$sid] = $fieldData;
                 }
             }
             unset($languages[$defLang]);
         }
         if (count($languages)) {
             foreach ($languages as $language => $langData) {
                 foreach ($langData as $sid => $fieldData) {
                     if (!isset($output[$sid])) {
                         $output[$sid] = $fieldData;
                     }
                 }
                 unset($languages[$language]);
             }
         }
     } catch (SPException $x) {
         Sobi::Error($this->name(), SPLang::e('CANNOT_GET_FIELDS_DATA_DB_ERR', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     $data = (array) $output;
     if (count($data)) {
         $fdata[''] = Sobi::Txt('FD.INBOX_SEARCH_SELECT', array('name' => $this->name));
         foreach ($data as $i => $d) {
             if (strlen($d)) {
                 $fdata[strip_tags($d)] = strip_tags($d);
             }
         }
     }
     return SPHtml_Input::select($this->nid, $fdata, $this->_selected, false, array('class' => $this->cssClass . ' ' . Sobi::Cfg('search.form_list_def_css', 'SPSearchSelect'), 'size' => '1', 'id' => $this->nid));
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:63,代码来源:inbox.php

示例14: saveData

 /**
  * Gets the data for a field and save it in the database
  * @param SPEntry $entry
  * @param string $request
  * @throws SPException
  * @return bool
  */
 public function saveData(&$entry, $request = 'POST')
 {
     if (!$this->enabled) {
         return false;
     }
     if ($this->method == 'fixed') {
         $fixed = $this->fixedCid;
         $fixed = explode(',', $fixed);
         $data = array();
         if (count($fixed)) {
             foreach ($fixed as $cid) {
                 $data[] = trim($cid);
             }
         }
         if (!count($data)) {
             throw new SPException(SPLang::e('FIELD_CC_FIXED_CID_NOT_SELECTED', $this->name));
         }
     } else {
         $data = $this->verify($entry, $request);
     }
     $time = SPRequest::now();
     $IP = SPRequest::ip('REMOTE_ADDR', 0, 'SERVER');
     $uid = Sobi::My('id');
     /* if we are here, we can save these data */
     /* @var SPdb $db */
     $db = SPFactory::db();
     /* collect the needed params */
     $params = array();
     $params['publishUp'] = $entry->get('publishUp');
     $params['publishDown'] = $entry->get('publishDown');
     $params['fid'] = $this->fid;
     $params['sid'] = $entry->get('id');
     $params['section'] = Sobi::Reg('current_section');
     $params['lang'] = Sobi::Lang();
     $params['enabled'] = $entry->get('state');
     $params['params'] = null;
     $params['options'] = null;
     $params['baseData'] = SPConfig::serialize($data);
     $params['approved'] = $entry->get('approved');
     $params['confirmed'] = $entry->get('confirmed');
     /* if it is the first version, it is new entry */
     if ($entry->get('version') == 1) {
         $params['createdTime'] = $time;
         $params['createdBy'] = $uid;
         $params['createdIP'] = $IP;
     }
     $params['updatedTime'] = $time;
     $params['updatedBy'] = $uid;
     $params['updatedIP'] = $IP;
     $params['copy'] = !$entry->get('approved');
     if (Sobi::My('id') == $entry->get('owner')) {
         --$this->editLimit;
     }
     $params['editLimit'] = $this->editLimit;
     /* save it */
     try {
         /* Notices:
          * If it was new entry - insert
          * If it was an edit and the field wasn't filled before - insert
          * If it was an edit and the field was filled before - update
          *     " ... " and changes are not autopublish it should be insert of the copy .... but
          * " ... " if a copy already exist it is update again
          * */
         $db->insertUpdate('spdb_field_data', $params);
     } catch (SPException $x) {
         Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
     }
     /* if it wasn't edited in the default language, we have to try to insert it also for def lang */
     if (Sobi::Lang() != Sobi::DefLang()) {
         $params['lang'] = Sobi::DefLang();
         try {
             $db->insert('spdb_field_data', $params, true, true);
         } catch (SPException $x) {
             Sobi::Error(__CLASS__, SPLang::e('CANNOT_SAVE_DATA', $x->getMessage()), SPC::WARNING, 0, __LINE__, __FILE__);
         }
     }
     /** Last important thing - join selected categories  */
     $cats = SPFactory::registry()->get('request_categories', array());
     $cats = array_unique(array_merge($cats, $data));
     SPFactory::registry()->set('request_categories', $cats);
     if ($this->method == 'select' && $this->isPrimary) {
         $db->update('spdb_object', array('parent' => $data[0]), array('id' => $params['sid']));
     }
 }
开发者ID:ranrolls,项目名称:ras-full-portal,代码行数:91,代码来源:category.php

示例15: checkTranslation

 protected function checkTranslation()
 {
     $lang = SPRequest::cmd('sp-language', false, 'get');
     if ($lang && $lang != Sobi::DefLang()) {
         $languages = SPFactory::CmsHelper()->availableLanguages();
         SPFactory::message()->info(Sobi::Txt('INFO_DIFFERENT_LANGUAGE', $this->_type, $languages[$lang]['name']), false);
     }
 }
开发者ID:pelloq1,项目名称:SobiPro,代码行数:8,代码来源:controller.php


注:本文中的Sobi::DefLang方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。