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


PHP CApp::getApp方法代码示例

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


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

示例1: getSetting

 /**
  * Получить настройку по псевдониму или ключевому полю
  *
  * @param $key
  * @return CSetting
  */
 public static function getSetting($key)
 {
     if (is_string($key)) {
         $key = strtoupper($key);
     }
     $cacheKey = CACHE_APPLICATION_SETTINGS . '_' . $key;
     if (!CApp::getApp()->cache->hasCache($cacheKey)) {
         $found = false;
         if (is_string($key)) {
             foreach (CActiveRecordProvider::getWithCondition(TABLE_SETTINGS, "UPPER(alias) = '" . $key . "'")->getItems() as $item) {
                 $found = true;
                 $setting = new CSetting($item);
                 CApp::getApp()->cache->set(CACHE_APPLICATION_SETTINGS . '_' . $setting->getId(), $setting);
                 CApp::getApp()->cache->set($cacheKey, $setting);
             }
         } elseif (is_numeric($key)) {
             $item = CActiveRecordProvider::getById(TABLE_SETTINGS, $key);
             if (!is_null($item)) {
                 $found = true;
                 $setting = new CSetting($item);
                 CApp::getApp()->cache->set(CACHE_APPLICATION_SETTINGS . '_' . $setting->alias, $setting);
                 CApp::getApp()->cache->set($cacheKey, $setting);
             }
         }
         if (!$found) {
             CApp::getApp()->cache->set($cacheKey, null);
         }
     }
     return CApp::getApp()->cache->get($cacheKey);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:36,代码来源:CSettingsManager.class.php

示例2: __callStatic

 /**
  * Магический метод получения любых классов
  *
  * @param $name
  * @param array $params
  * @throws Exception
  */
 public static function __callStatic($name, $params = array())
 {
     /**
      * Получаем имя класса из имени функции
      */
     $className = "C" . CUtils::strRight($name, "get");
     if (!class_exists($className)) {
         throw new Exception("В приложении не объявлен класс " . $className);
     }
     /**
      * @var CActiveModel $simpleClass
      */
     $simpleClass = new $className();
     $table = $simpleClass->getRecord()->getTable();
     $id = $params[0];
     /**
      * Попробуем сначала получить из кэша
      */
     $keySeek = $table . "_" . $id;
     if (CApp::getApp()->cache->hasCache($keySeek)) {
         return CApp::getApp()->cache->get($keySeek);
     }
     $ar = CActiveRecordProvider::getById($table, $id);
     if (!is_null($ar)) {
         $obj = new $className($ar);
         CApp::getApp()->cache->set($keySeek, $obj, 60);
         return $obj;
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:36,代码来源:CBaseManager.class.php

示例3: actionGetObject

 public function actionGetObject($id)
 {
     $cache_id = $this->taxonomy . "_item_" . $id;
     if (is_null(CApp::getApp()->cache->get($cache_id))) {
         $taxonomy = CTaxonomyManager::getTaxonomy($this->taxonomy);
         $term = $taxonomy->getTerm($id);
         CApp::getApp()->cache->set($cache_id, $term, 30);
     }
     return CApp::getApp()->cache->get($cache_id);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:10,代码来源:CSearchCatalogTaxonomy.class.php

示例4: serializeBean

 /**
  * Сериализовать бин на диск
  *
  * @param CStatefullBean $bean
  */
 public function serializeBean(CStatefullBean $bean)
 {
     if (is_a(CApp::getApp()->getApp(), "CCacheDummy")) {
         if (file_exists($this->cacheDir . $bean->getBeanId())) {
             unlink($this->cacheDir . $bean->getBeanId());
         }
         file_put_contents($this->cacheDir . $bean->getBeanId(), serialize($bean));
     } else {
         CApp::getApp()->cache->set("bean_" . $bean->getBeanId(), $bean);
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:16,代码来源:CBeanManager.class.php

示例5: getCacheSettings

 /**
  * @return CArrayList|null
  */
 private static function getCacheSettings()
 {
     if (is_null(self::$_cacheSettings)) {
         self::$_cacheSettings = new CArrayList();
         if (CSettingsManager::getSettingValue("preload_settings")) {
             // будет с поддержкой кеша
             if (is_null(CApp::getApp()->cache->get(CACHE_APPLICATION_SETTINGS))) {
                 foreach (CActiveRecordProvider::getAllFromTable(TABLE_SETTINGS)->getItems() as $item) {
                     $setting = new CSetting($item);
                     self::getCacheSettings()->add($setting->getId(), $setting);
                     self::getCacheSettings()->add(strtoupper($setting->alias), $setting);
                 }
                 CApp::getApp()->cache->set(CACHE_APPLICATION_SETTINGS, self::$_cacheSettings, 3600);
             } else {
                 self::$_cacheSettings = CApp::getApp()->cache->get(CACHE_APPLICATION_SETTINGS);
             }
         }
     }
     return self::$_cacheSettings;
 }
开发者ID:Trozeman,项目名称:ASUPortalPHP,代码行数:23,代码来源:CSettingsManager.class.php

示例6: getReportData

 public function getReportData()
 {
     $result = array();
     // получаем данные о статистике
     // за промежуток времени
     $condition = "time_stamp BETWEEN '" . date("Y-m-d", strtotime($this->start)) . "' AND '" . date("Y-m-d", strtotime($this->end)) . "'";
     $condition .= " and (s.q_string like '%action=search%'";
     $condition .= " or s.q_string like '%action=getGlobalSearchSubform%'";
     $condition .= " or s.q_string like '%action=LookupGetCreationDialog%'";
     $condition .= " or s.q_string like '%action=GlobalSearch%'";
     $condition .= " or s.q_string like '%action=LookupGetDialog%'";
     $condition .= " or s.q_string like '%action=LookupGetItem%'";
     $condition .= " or s.q_string like '%action=LookupTypeAhead%' )";
     $query = new CQuery(CApp::getApp()->getDbLogConnection());
     $select = "month(s.time_stamp) as t_stamp_m, year(s.time_stamp) as t_stamp_y, count(id) as cnt";
     $select .= ", concat(month(s.time_stamp), '.', year(s.time_stamp)) as t_stamp";
     $query->select($select)->from("stats as s")->condition($condition)->group("t_stamp_m")->order("t_stamp_y desc, t_stamp_m desc");
     $result = $query->execute()->getItems();
     $res = array();
     foreach ($result as $row) {
         $data = array("t_stamp" => $row["t_stamp"], "cnt" => $row["cnt"], "total" => 0);
         $res[$row["t_stamp"]] = $data;
     }
     $condition = "time_stamp BETWEEN '" . date("Y-m-d", strtotime($this->start)) . "' AND '" . date("Y-m-d", strtotime($this->end)) . "'";
     $query = new CQuery(CApp::getApp()->getDbLogConnection());
     $select = "month(s.time_stamp) as t_stamp_m, year(s.time_stamp) as t_stamp_y, count(id) as cnt";
     $select .= ", concat(month(s.time_stamp), '.', year(s.time_stamp)) as t_stamp";
     $query->select($select)->from("stats as s")->condition($condition)->group("t_stamp_m")->order("t_stamp_y desc, t_stamp_m desc");
     $result = $query->execute()->getItems();
     foreach ($result as $row) {
         if (array_key_exists($row["t_stamp"], $res)) {
             $res[$row["t_stamp"]]["total"] = $row["cnt"];
         }
     }
     return $res;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:36,代码来源:CReportSearchStatistics.class.php

示例7: getCoreModelFieldTranslation

 /**
  * @param $key
  * @return CCoreModelFieldTranslation
  */
 public static function getCoreModelFieldTranslation($key)
 {
     if (!CApp::getApp()->cache->hasCache("core_model_field_translation_" . $key)) {
         $ar = null;
         if (is_numeric($key)) {
             $ar = CActiveRecordProvider::getById(TABLE_CORE_MODEL_FIELD_TRANSLATIONS, $key);
         }
         if (!is_null($ar)) {
             $t = new CCoreModelFieldTranslation($ar);
             CApp::getApp()->cache->set("core_model_field_translation_" . $key, $t, 300);
         }
     }
     return CApp::getApp()->cache->get("core_model_field_translation_" . $key);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:18,代码来源:CCoreObjectsManager.class.php

示例8: execute

 public function execute($contextObject)
 {
     /**
      * @var $bean CStatefullBean
      */
     $bean = CApp::getApp()->beans->getStatefullBean(CRequest::getString("beanId"));
     $persons = new CArrayList();
     foreach ($bean->getItem("id")->getItems() as $person_id) {
         $person = CStaffManager::getPerson($person_id);
         if (!is_null($person)) {
             $persons->add($person->getId(), $person);
         }
     }
     /**
      * Отфильтруем нужные планы
      */
     $targetPlans = new CArrayList();
     /**
      * @var $person CPerson
      */
     foreach ($persons->getItems() as $person) {
         foreach ($person->getIndPlansByYears($bean->getItem("year_id"))->getItems() as $year_id => $plans) {
             foreach ($plans->getItems() as $plan) {
                 if (in_array($plan->type, $bean->getItem("types")->getItems())) {
                     $targetPlans->add($plan->getId(), $plan);
                 }
             }
         }
     }
     $month = $bean->getItem("month");
     $month = $month->getFirstItem();
     $result = array();
     /**
      * @var $plan CIndPlanPersonLoad
      */
     foreach ($targetPlans->getItems() as $plan) {
         $row = array();
         $row[0] = "";
         $row[1] = "";
         $row[2] = "";
         $row[3] = "";
         $row[4] = "";
         // план на семестр
         if (!array_key_exists(5, $row)) {
             $row[5] = 0;
         }
         $preparedData = array();
         $table = $plan->getStudyLoadTable()->getTable();
         foreach ($table as $r) {
             if ($plan->isSeparateContract()) {
                 // если есть бюджет-контракт, то суммируем их
                 $preparedRow = array();
                 $preparedRow[0] = $r[0];
                 for ($i = 1; $i <= 17; $i++) {
                     $preparedRow[$i] = $r[$i * 2] + $r[$i * 2 - 1];
                 }
                 $preparedData[] = $preparedRow;
             } else {
                 // нет разделения на бюджет-контракт, копируем
                 $preparedData[] = $r;
             }
         }
         if (in_array($month, array(2, 3, 4, 5, 6))) {
             foreach ($preparedData as $preparedRow) {
                 $row[5] += $preparedRow[1];
             }
         } else {
             foreach ($preparedData as $preparedRow) {
                 $row[5] += $preparedRow[8];
             }
         }
         $rows = array(6 => 0, 7 => 1, 8 => 2, 9 => -1, 10 => 4, 11 => -1, 12 => 14, 13 => 3, 14 => 5, 15 => 6, 16 => 7, 17 => 8, 18 => 9, 19 => 10, 20 => 15, 21 => 16);
         foreach ($rows as $target => $source) {
             if (!array_key_exists($target, $row)) {
                 $row[$target] = 0;
             }
             if ($source != -1) {
                 $row[$target] += $preparedData[$source][$month];
             }
         }
         if (!array_key_exists(22, $row)) {
             $row[22] = 0;
         }
         for ($i = 6; $i <= 21; $i++) {
             $row[22] += $row[$i];
         }
         $result[] = $row;
     }
     $sum = array();
     $sum[0] = "Итог";
     for ($i = 1; $i <= 4; $i++) {
         $sum[$i] = "";
     }
     for ($i = 5; $i <= 22; $i++) {
         if (!array_key_exists($i, $sum)) {
             $sum[$i] = 0;
         }
         foreach ($result as $item) {
             $sum[$i] += $item[$i];
         }
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CIndPlanPersonsReportTableTotal.class.php

示例9: getUserGroup

 /**
  * Группа пользователей
  *
  * @static
  * @param $key
  * @return CUserGroup
  */
 public static function getUserGroup($key)
 {
     if (!self::getCacheUserGroups()->hasElement($key)) {
         $cache_id = "staff_user_group_" . $key;
         if (is_null(CApp::getApp()->cache->get($cache_id))) {
             $ar = CActiveRecordProvider::getById(TABLE_USER_GROUPS, $key);
             $group = null;
             if (!is_null($ar)) {
                 $group = new CUserGroup($ar);
                 CApp::getApp()->cache->set($cache_id, $group, 3600);
             }
         }
         $group = CApp::getApp()->cache->get($cache_id);
         self::getCacheUserGroups()->add($group->getId(), $group);
     }
     return self::getCacheUserGroups()->getItem($key);
 }
开发者ID:Trozeman,项目名称:ASUPortalPHP,代码行数:24,代码来源:CStaffManager.class.php

示例10: getSmarty

 /**
  * @return Smarty
  */
 protected function getSmarty()
 {
     if (is_null($this->_smarty)) {
         // подключаем Smarty
         $config = CApp::getApp()->getConfig();
         $smartyConfig = $config["smarty"];
         $this->_smarty = new Smarty();
         $this->_smarty->caching = $smartyConfig["cacheEnabled"];
         $this->_smarty->setTemplateDir(SMARTY_TEMPLATES);
         $this->_smarty->setCompileDir(SMARTY_COMPILE);
         $this->_smarty->setCacheDir(SMARTY_CACHE);
         // постоянно нужная ерунда типа управлялки меню,
         // нет другого места, откуда ее можно хорошо подцепить
         $this->addCSSInclude("_core/core.css");
     }
     return $this->_smarty;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:20,代码来源:CBaseController.class.php

示例11: execute

 public function execute($contextObject)
 {
     /**
      * @var $bean CStatefullBean
      */
     $bean = CApp::getApp()->beans->getStatefullBean(CRequest::getString("beanId"));
     $persons = new CArrayList();
     foreach ($bean->getItem("id")->getItems() as $person_id) {
         $person = CStaffManager::getPerson($person_id);
         if (!is_null($person)) {
             $persons->add($person->getId(), $person);
         }
     }
     /**
      * Отфильтруем нужные планы
      */
     $targetPlans = new CArrayList();
     /**
      * @var $person CPerson
      */
     foreach ($persons->getItems() as $person) {
         foreach ($person->getIndPlansByYears($bean->getItem("year_id"))->getItems() as $year_id => $plans) {
             foreach ($plans->getItems() as $plan) {
                 if (in_array($plan->type, $bean->getItem("types")->getItems())) {
                     $targetPlans->add($plan->getId(), $plan);
                 }
             }
         }
     }
     $month = $bean->getItem("month");
     $month = $month->getFirstItem();
     $result = array();
     /**
      * @var $plan CIndPlanPersonLoad
      */
     foreach ($targetPlans->getItems() as $plan) {
         $row = array();
         if (array_key_exists($plan->person_id, $result)) {
             $row = $result[$plan->person_id];
         }
         $row[0] = "АСУ";
         $row[1] = count($result);
         $row[2] = "";
         if (!is_null($plan->person)) {
             if (!is_null($plan->person->getPost())) {
                 $row[2] = $plan->person->getPost()->name_short;
             }
         }
         $row[3] = "";
         if (!is_null($plan->person)) {
             if (!is_null($plan->person->degree)) {
                 $row[3] = $plan->person->degree->comment;
             }
         }
         $row[4] = "";
         if (!is_null($plan->person)) {
             $row[4] = $plan->person->fio_short;
         }
         // план на семестр бюджет
         if (!array_key_exists(5, $row)) {
             $row[5] = 0;
         }
         // план на семестр контракт
         if (!array_key_exists(6, $row)) {
             $row[6] = 0;
         }
         // итого бюджет
         if (!array_key_exists(23, $row)) {
             $row[23] = 0;
         }
         // итого контракт
         if (!array_key_exists(24, $row)) {
             $row[24] = 0;
         }
         $preparedData = array();
         $table = $plan->getStudyLoadTable()->getTable();
         foreach ($table as $r) {
             if ($plan->isSeparateContract()) {
                 // если есть бюджет-контракт, то суммируем их
                 $preparedRow = array();
                 $preparedRow[0] = $r[0];
                 for ($i = 1; $i <= 17; $i++) {
                     $preparedRow[$i] = $r[$i * 2] + $r[$i * 2 - 1];
                 }
                 // не разделяем бюджет-контракт плана на осенний семестр
                 $preparedRow[18] = $r[1];
                 $preparedRow[19] = $r[2];
                 // не разделяем бюджет-контракт плана на весенний семестр
                 $preparedRow[20] = $r[15];
                 $preparedRow[21] = $r[16];
                 // не разделяем бюджет-контракт итога за осенний семестр
                 $preparedRow[20] = $r[13];
                 $preparedRow[21] = $r[14];
                 // не разделяем бюджет-контракт итога за весенний семестр
                 $preparedRow[22] = $r[29];
                 $preparedRow[23] = $r[30];
                 $preparedData[] = $preparedRow;
             } else {
                 // нет разделения на бюджет-контракт, копируем
                 $preparedData[] = $r;
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CIndPlanPersonsReportTableByTime.class.php

示例12: __get

 /**
  * Волшебный геттер
  * @param type $name
  */
 public function __get($name)
 {
     // проверка на наличие маппинга свойства на поле БД
     $mapping = $this->fieldsMapping();
     if (array_key_exists($name, $mapping)) {
         $name = $mapping[$name];
     }
     // проверяем, не обычное ли это поле
     if (array_key_exists($name, $this->getRecord()->getItems())) {
         // обходной маневр для конвертации mysql-дат в отечественные
         $properties = $this->fieldsProperty();
         if (array_key_exists($name, $properties)) {
             $property = $properties[$name];
             if (array_key_exists("type", $property)) {
                 if ($property["type"] == FIELD_MYSQL_DATE) {
                     $value = $this->getRecord()->getItemValue($name);
                     if (strpos($value, "0000-00-00") !== false) {
                         return "";
                     }
                     return date($property["format"], strtotime($value));
                 }
             }
         }
         return $this->getRecord()->getItemValue($name);
     }
     // поле необычное.
     $relations = $this->relations();
     if (array_key_exists($name, $relations)) {
         $relation = $relations[$name];
         // разрешим не указывать
         if (!array_key_exists("storageProperty", $relation)) {
             $relation["storageProperty"] = "_" . $name;
         }
         if ($relation['relationPower'] == RELATION_HAS_ONE) {
             $private = $relation['storageProperty'];
             if (is_null($this->{$private})) {
                 $key_field = $relation['storageField'];
                 $key_value = $this->{$key_field};
                 $useManager = true;
                 if (array_key_exists("targetClass", $relation)) {
                     $targetClass = $relation["targetClass"];
                     $useManager = false;
                 } else {
                     $managerClass = $relation['managerClass'];
                     $managerGetter = $relation['managerGetObject'];
                 }
                 if ($useManager) {
                     $obj = $managerClass::$managerGetter($key_value);
                 } else {
                     $targetClass = "get" . mb_substr($targetClass, 1);
                     $obj = CBaseManager::$targetClass($key_value);
                 }
                 $this->{$private} = $obj;
             }
             return $this->{$private};
         } elseif ($relation['relationPower'] == RELATION_HAS_MANY) {
             $private = $relation['storageProperty'];
             /**
              * Проверим, вдруг разрешено использование кэш
              * и данные кэше уже есть
              */
             $useCache = false;
             if (array_key_exists("useCache", $relation)) {
                 $useCache = $relation["useCache"];
             }
             if ($useCache) {
                 $cacheKey = get_class($this) . "_property_" . $name . "_" . $this->getId();
                 if (CApp::getApp()->cache->hasCache($cacheKey)) {
                     $valueFromCache = CApp::getApp()->cache->get($cacheKey);
                     $this->{$private} = $valueFromCache;
                 }
             }
             if (is_null($this->{$private})) {
                 $table = $relation['storageTable'];
                 $condition = $relation['storageCondition'];
                 $useManager = true;
                 if (array_key_exists("targetClass", $relation)) {
                     $targetClass = $relation["targetClass"];
                     $useManager = false;
                 } else {
                     $managerClass = $relation['managerClass'];
                     $managerGetter = $relation['managerGetObject'];
                 }
                 $managerOrder = null;
                 if (array_key_exists("managerOrder", $relation)) {
                     $managerOrder = $relation['managerOrder'];
                 }
                 $this->{$private} = new CArrayList();
                 foreach (CActiveRecordProvider::getWithCondition($table, $condition, $managerOrder)->getItems() as $item) {
                     if ($useManager) {
                         $obj = $managerClass::$managerGetter($item->getId());
                     } else {
                         $obj = new $targetClass($item);
                     }
                     if (!is_null($obj)) {
                         if (is_object($obj)) {
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CActiveModel.class.php

示例13: getRoles

 /**
  * Лист ролей, которыми должен обладать пользователь, чтобы
  * видеть данный пункт меню (как минимум, одной)
  *
  * @return CArrayList
  */
 public function getRoles()
 {
     if (is_null($this->_roles)) {
         if (!CApp::getApp()->cache->hasCache("menu_item_access_" . $this->getId())) {
             $this->_roles = new CArrayList();
             foreach (CActiveRecordProvider::getWithCondition(TABLE_MENU_ITEMS_ACCESS, "item_id = " . $this->getId())->getItems() as $item) {
                 $role = CStaffManager::getUserRole($item->getItemValue("role_id"));
                 if (!is_null($role)) {
                     $this->_roles->add($role->getId(), $role);
                 }
             }
             CApp::getApp()->cache->set("menu_item_access_" . $this->getId(), $this->_roles, 300);
         }
         $this->_roles = CApp::getApp()->cache->get("menu_item_access_" . $this->getId());
     }
     return $this->_roles;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:23,代码来源:CMenuItem.class.php

示例14: renderView

 /**
  * Отрисовать представление, результаты будут переданы указанному
  * классу и его методу
  *
  * @param $view
  * @param $targetClass
  * @param $targetMethod
  */
 public function renderView($view, $targetClass = "", $targetMethod = "")
 {
     $this->setData("targetClass", $targetClass);
     $this->setData("targetMethod", $targetMethod);
     CApp::getApp()->beans->serializeBean(self::getStatefullBean());
     $this->setData("beanId", self::getStatefullBean()->getBeanId());
     parent::renderView($view);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:16,代码来源:CFlowController.class.php

示例15: getStatefullFormBean

 /**
  * @return CStatefullFormBean
  */
 protected function getStatefullFormBean()
 {
     if (is_null($this->_statefullBean)) {
         $this->_statefullBean = new CStatefullFormBean();
         if (CRequest::getString(FORM_BEAN) != "") {
             $this->_statefullBean = CApp::getApp()->beans->getStatefullBean(CRequest::getString(FORM_BEAN));
         }
     }
     return $this->_statefullBean;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:13,代码来源:CStatefullFormController.class.php


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