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


PHP CArrayList::getCount方法代码示例

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


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

示例1: actionWizardCompleted

 public function actionWizardCompleted()
 {
     $speciality = CTaxonomyManager::getCacheSpecialities()->getItem(CRequest::getInt("speciality_id"));
     $year = CTaxonomyManager::getCacheYears()->getItem(CRequest::getInt("year_id"));
     $protocol = CProtocolManager::getDepProtocol(CRequest::getInt("protocol_id"));
     $signer = CStaffManager::getPersonById(CRequest::getInt("signer_id"));
     $disciplines = new CArrayList();
     foreach (CRequest::getArray("discipline") as $i) {
         $disciplines->add($disciplines->getCount(), CDisciplinesManager::getDiscipline($i));
     }
     // бегаем по циклу столько раз, сколько нам билетов нужно
     for ($i = 1; $i <= CRequest::getInt("count"); $i++) {
         $ticket = CFactory::createSebTicket();
         $ticket->setSpeciality($speciality);
         $ticket->setYear($year);
         $ticket->setProtocol($protocol);
         $ticket->setSigner($signer);
         $ticket->setNumber($i);
         foreach ($disciplines->getItems() as $disc) {
             if ($disc->getQuestions()->getCount() == 0) {
                 break;
             }
             $question = $disc->getQuestions()->getShuffled()->getFirstItem();
             $disc->getQuestions()->removeItem($question->getId());
             $ticket->addQuestion($question);
         }
         $ticket->save();
     }
     $this->redirect("?action=index");
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:30,代码来源:CSEBTicketsController.class.php

示例2: actionSelectYearsByPersonsPlans

 /**
  * Соберем все года, за которые у выбранных пользователей есть
  * индивидуальные планы
  */
 public function actionSelectYearsByPersonsPlans()
 {
     $bean = self::getStatefullBean();
     $ids = explode(":", $bean->getItem("id"));
     $bean->add("id", new CArrayList($ids));
     $persons = new CArrayList();
     foreach ($ids as $id) {
         $person = CStaffManager::getPerson($id);
         if (!is_null($person)) {
             $persons->add($person->getId(), $person);
         }
     }
     $years = new CArrayList();
     /**
      * @var $person CPerson
      */
     foreach ($persons->getItems() as $person) {
         foreach ($person->getIndPlansByYears()->getItems() as $year_id => $data) {
             $year = CTaxonomyManager::getYear($year_id);
             if (!is_null($year)) {
                 $years->add($year->getId(), $year->getValue());
             }
         }
     }
     if ($years->getCount() == 0) {
         $this->setData("message", "Год не выбран, продолжение невозможно");
         $this->renderView("_flow/dialog.ok.tpl", "", "");
         return true;
     }
     $this->setData("items", $years);
     $this->renderView("_flow/pickList.tpl", get_class($this), "SelectLoadTypesByPersonsPlans");
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:36,代码来源:CIndPlanPrintController.class.php

示例3: display

 /**
  * Отображение организационной структуры.
  *
  * Параметры вызова:
  * array(
  *      'items' => CArrayList,
  *      'itemTemplate' => '_item.html.php'
  * )
  *
  * CArrayList должен содержать объекты типа CPerson
  *
  * @static
  * @param array $arr
  */
 public static function display(array $arr = null)
 {
     $r = new CArrayList();
     foreach ($arr['items']->getItems() as $i) {
         if ($i->getSubordinators()->getCount() > 0 && $i->getManagerId() == 0) {
             $r->add($r->getCount(), $i);
         }
     }
     CUnorderedListWidget::display(array('items' => $r, 'itemTemplate' => '_orgStructureItem.html.php', 'id' => $arr['id'], 'style' => $arr['style']));
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:24,代码来源:COrgStructureWidget.class.php

示例4: actionView

 public function actionView()
 {
     $set = new CRecordSet(false);
     $query = new CQuery();
     $set->setQuery($query);
     $query->select("DISTINCT subject.*")->from(TABLE_DISCIPLINES . " as subject")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "doc.subj_id = subject.id")->condition("doc.user_id = " . CRequest::getFilter("author"))->order("subject.name asc");
     $selectedUser = null;
     $usersQuery = new CQuery();
     $usersQuery->select("user.*")->from(TABLE_USERS . " as user")->order("user.fio asc")->innerJoin(TABLE_LIBRARY_DOCUMENTS . " as doc", "user.id = doc.user_id");
     // фильтр по автору
     if (!is_null(CRequest::getFilter("author"))) {
         $selectedUser = CRequest::getFilter("author");
         $author = CRequest::getFilter("author");
     } else {
         $query->condition("doc.user_id = " . CSession::getCurrentUser()->getId());
         $author = CSession::getCurrentUser()->getId();
     }
     $users = array();
     foreach ($usersQuery->execute()->getItems() as $ar) {
         $user = new CUser(new CActiveRecord($ar));
         $users[$user->getId()] = $user->getName();
     }
     $folders = new CArrayList();
     foreach ($set->getPaginated()->getItems() as $ar) {
         $folder = new CLibraryFolder(new CTerm($ar));
         $folders->add($folders->getCount(), $folder);
     }
     $this->addActionsMenuItem(array(array("title" => "Назад", "link" => WEB_ROOT . "_modules/_library/index.php", "icon" => "actions/edit-undo.png")));
     if (CSession::isAuth() and (CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_OWN_ONLY or CSession::getCurrentUser()->getLevelForCurrentTask() == ACCESS_LEVEL_WRITE_ALL)) {
         $this->addActionsMenuItem(array(array("title" => "Добавить предмет", "link" => WEB_ROOT . "_modules/_library/index.php?action=addDocument&filter=author:" . $author, "icon" => "actions/list-add.png")));
     }
     $this->addCSSInclude(JQUERY_UI_CSS_PATH);
     $this->addJSInclude(JQUERY_UI_JS_PATH);
     $this->setData("folders", $folders);
     $this->setData("users", $users);
     $this->setData("selectedUser", $selectedUser);
     $this->setData("author", $author);
     $this->setData("paginator", $set->getPaginator());
     $this->renderView("_library/view.tpl");
 }
开发者ID:Trozeman,项目名称:ASUPortalPHP,代码行数:40,代码来源:CPublicLibraryController.class.php

示例5: getModelValidators

 /**
  * Получаем валидаторы из модели
  *
  * @param CModel $model
  * @return CArrayList
  */
 public static function getModelValidators(CModel $model)
 {
     $validators = new CArrayList();
     $coreModel = self::getCoreModel(get_class($model));
     if (!is_null($coreModel)) {
         foreach ($coreModel->validators->getItems() as $validator) {
             if (!is_null($validator->validator)) {
                 $val = $validator->validator;
                 $class_name = $val->class_name;
                 $obj = new $class_name();
                 $validators->add($validators->getCount(), $obj);
             }
         }
     }
     return $validators;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:22,代码来源:CCoreObjectsManager.class.php

示例6: queryCustom

 private function queryCustom()
 {
     if (is_object($this->getDb())) {
         $start = microtime();
         $res = new CArrayList();
         $this->_result = $this->getDb()->prepare($this->getQueryString());
         $this->_result->execute();
         foreach ($this->_result->fetchAll(PDO::FETCH_ASSOC) as $row) {
             $res->add($res->getCount(), $row);
         }
         $end = microtime();
         CLog::writeToLog($this->getQueryString() . " (" . ($end - $start) . ")");
         CLog::addQueryTime($end - $start);
         return $res;
     } else {
         $start = microtime();
         $res = new CArrayList();
         $q = mysql_query($this->getQueryString(), $this->getDb()) or die(mysql_error($this->getDb()) . " -> " . $this->getQueryString());
         if (mysql_affected_rows($this->getDb()) > 0) {
             while ($row = mysql_fetch_assoc($q)) {
                 $res->add($res->getCount(), $row);
             }
         }
         $end = microtime();
         CLog::writeToLog($this->getQueryString() . " (" . ($end - $start) . ")");
         CLog::addQueryTime($end - $start);
         return $res;
     }
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:29,代码来源:CQuery.class.php

示例7: toGradebookTable

 /**
  * Преобразовать плоскую таблицу в журнал
  *
  * @return CArrayList
  */
 public function toGradebookTable()
 {
     $rows = new CArrayList();
     // шаг 1. определим количество записей в одной строке
     $types = new CArrayList();
     $dates = new CArrayList();
     $comments = new CArrayList();
     foreach ($this->activities->getItems() as $activity) {
         if (!is_null($activity->controlType)) {
             /*
             $types->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->controlType->getValue());
             $dates->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->getDate());
             $comments->add($activity->study_act_id."_".str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT)."_".date("Ymd", strtotime($activity->getDate())), $activity->study_act_comment);
             */
             $types->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->controlType->getValue());
             $dates->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->getDate());
             $comments->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $activity->study_act_comment);
         }
     }
     $types = $types->getSortedByKey(SORT_ASC);
     $dates = $dates->getSortedByKey(SORT_ASC);
     $firstCol = new CArrayList();
     $firstCol->add($firstCol->getCount(), "");
     // добавим все виды деятельности
     foreach ($types->getItems() as $key => $type) {
         $firstCol->add($key, $type);
     }
     $rows->add($rows->getCount(), $firstCol);
     // все номера лабораторных работ
     $col = $firstCol->getCopy();
     foreach ($comments->getItems() as $key => $date) {
         $col->add($key, $date);
     }
     $rows->add($rows->getCount(), $col);
     // шаг 2. пройдемся по всем записям, получим всех студентов
     $students = new CArrayList();
     foreach ($this->activities->getItems() as $activity) {
         if (!is_null($activity->student)) {
             $students->add($activity->student->getName(), $activity->student);
         }
     }
     $students = $students->getSortedByKey(SORT_ASC);
     // шаг 3. создадим на каждого студента по строчке в таблице
     foreach ($students->getItems() as $student) {
         $col = $firstCol->getCopy();
         foreach ($col->getItems() as $key => $value) {
             if ($key !== 0) {
                 $col->add($key, "");
             }
         }
         $col->add(0, $student->getName());
         foreach ($this->activities->getItems() as $activity) {
             if ($activity->student_id == $student->getId()) {
                 $arr = array();
                 if ($col->hasElement($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT))) {
                     $arr = $col->getItem($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT));
                 }
                 if (!is_null($activity->mark)) {
                     $arr[] = $activity->mark->getValue();
                 }
                 $col->add($activity->study_act_id . "_" . str_pad($activity->study_act_comment, 4, "0", STR_PAD_LEFT), $arr);
             }
         }
         $rows->add($rows->getCount(), $col);
     }
     // по просьбе ГВ в клетку 1.1 ставим название группы
     if (!is_null($this->group)) {
         $firstCol->add(0, $this->group->getName());
     }
     return $rows;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:76,代码来源:CGradebook.class.php

示例8: getQuestionsByParams

 /**
  * Сгенерировать указанное количество вопросов по указанным параметрам
  *
  * @param $speciality_id
  * @param $course
  * @param $year_id
  * @param $discipline_id
  * @param $category_id
  * @param $count
  * @return CArrayList
  */
 private function getQuestionsByParams($speciality_id, $course, $year_id, $discipline_id, $category_id, $count)
 {
     $res = new CArrayList();
     // получим все вопросы по указанной дисциплине
     $questions = new CArrayList();
     foreach (CExamManager::getAllQuestions()->getItems() as $q) {
         if ($q->speciality_id == $speciality_id) {
             if ($q->course == $course) {
                 if ($q->year_id == $year_id) {
                     if ($q->discipline_id == $discipline_id) {
                         if ($q->category_id == $category_id) {
                             $questions->add($q->getId(), $q);
                         }
                     }
                 }
             }
         }
     }
     // если ничего не нашлось, то выходим
     if ($questions->getCount() == 0) {
         return $res;
     }
     // если полученное количество вопросов больше требуемого, то берем
     // случайные значения, если меньше, то тоже берем случайные значения
     // до тех пор, пока не наберем столько, сколько надо
     if ($questions->getCount() >= $count) {
         for ($i = 0; $i < $count; $i++) {
             $q = $questions->getShuffled()->getFirstItem();
             $res->add($res->getCount(), $q);
             $questions->removeItem($q->getId());
         }
     } else {
         $backup = $questions->getCopy();
         $i = 0;
         while ($i < $count) {
             $q = $questions->getShuffled()->getFirstItem();
             $res->add($res->getCount(), $q);
             $questions->removeItem($q->getId());
             if ($questions->getCount() == 0) {
                 $questions = $backup->getCopy();
             }
             $i++;
         }
     }
     return $res;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:57,代码来源:CExaminationController.class.php

示例9: actionIndex

 public function actionIndex()
 {
     $this->addCSSInclude("_modules/_dashboard/style.css");
     $items = new CArrayList();
     /**
      * Показываем пункты рабочего стола в зависимости от
      * личных настроек пользователя
      */
     if (!is_null(CSession::getCurrentUser()->getPersonalSettings())) {
         $settings = CSession::getCurrentUser()->getPersonalSettings();
         /**
          * Показ дней рождения на этой недел
          */
         if ($settings->isShowBirthdays()) {
             if (CStaffManager::getBirthdaysThisWeek()->getCount() > 0) {
                 $cnt = 0;
                 $item = new CDashboardItem();
                 $item->id = "birthdays";
                 $item->title = "Дни рождения";
                 $item->icon = "mimetypes/text-x-java.png";
                 $items->add("_" . $items->getCount(), $item);
                 foreach (CStaffManager::getBirthdaysThisWeek()->getItems() as $person) {
                     $child = new CDashboardItem();
                     $child->id = "person_" . $person->getId();
                     $child->title = $person->getName() . " (" . $person->getBirthday() . ")";
                     $item->addChild($child);
                     $cnt++;
                     if ($cnt == 2) {
                         $child = new CDashboardItem();
                         $child->id = "person_q";
                         $child->title = "Всего " . CStaffManager::getBirthdaysThisWeek()->getCount();
                         $item->addChild($child);
                         break;
                     }
                 }
             }
         }
         /**
          * Показываем сообщения
          */
         if ($settings->isShowMessages()) {
             $item = new CDashboardItem();
             $item->title = "Сообщения";
             $item->icon = "apps/evolution.png";
             $item->addChild(null);
             if (CSession::getCurrentUser()->getUnreadMessages()->getCount() > 0) {
                 $child = new CDashboardItem();
                 $child->id = "inbox";
                 $child->title = "Входящие (" . CSession::getCurrentUser()->getUnreadMessages()->getCount() . ")";
                 $child->link = "mail.php?folder=in";
                 $item->addChild($child);
             } else {
                 $child = new CDashboardItem();
                 $child->id = "inbox";
                 $child->title = "Нет непрочитанных сообщений";
                 $child->link = "mail.php?folder=in";
                 $item->addChild($child);
             }
             $child = new CDashboardItem();
             $child->id = "new";
             $child->title = "Написать сообщение";
             $child->link = "mail.php?compose=1";
             $item->addChild($child);
             $items->add("_" . $items->getCount(), $item);
         }
     }
     $set = CActiveRecordProvider::getWithCondition(TABLE_DASHBOARD, "user_id = " . CSession::getCurrentUser()->getId() . " and parent_id = 0");
     foreach ($set->getItems() as $ar) {
         $item = new CDashboardItem($ar);
         $items->add($item->getId(), $item);
     }
     /**
      * Личный рабочий стол
      */
     $dashboards = new CArrayList();
     $dashboards->add("Личный рабочий стол", $items);
     /**
      * Соберем рабочие столы групп, в которые входит пользователь
      */
     $groups = CSession::getCurrentUser()->getGroups();
     foreach ($groups->getItems() as $group) {
         $dashboards->add($group->comment, $group->dashboardItems);
     }
     $roles = new CArrayList();
     foreach (CSession::getCurrentUser()->getRoles()->getItems() as $role) {
         if ($role->hidden != 1) {
             $roles->add($role->getId(), $role);
         }
     }
     $sort = new CArrayList();
     foreach ($roles->getItems() as $i) {
         $sort->add($i->name, $i->getId());
     }
     $tasks = new CArrayList();
     foreach ($sort->getSortedByKey(true)->getItems() as $i) {
         $item = $roles->getItem($i);
         $tasks->add($item->getId(), $item);
     }
     $this->setData("tasks", $tasks);
     $this->setData("dashboards", $dashboards);
//.........这里部分代码省略.........
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:101,代码来源:CDashboardController.class.php

示例10: getTaxonomiesObjectList

 /**
  * Лист таксономий в виде объектов
  *
  * @static
  * @return CArrayList
  */
 public static function getTaxonomiesObjectList()
 {
     $res = new CArrayList();
     foreach (self::getCacheTaxonomy()->getItems() as $key => $value) {
         if (is_int($key)) {
             $res->add($res->getCount(), $value);
         }
     }
     return $res;
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:16,代码来源:CTaxonomyManager.class.php

示例11: actionSearch

 public function actionSearch()
 {
     $term = CRequest::getString("query");
     $result = array();
     // извлекаем все папки и файлы, у которых что-то совпадает
     $query = new CQuery();
     $query->select("f.*")->from(TABLE_DOCUMENT_FOLDERS . " as f")->condition("f.title like '%" . $term . "%'")->order("f.title asc");
     $objects = new CArrayList();
     foreach ($query->execute()->getItems() as $ar) {
         $folder = new CDocumentFolder(new CActiveRecord($ar));
         $objects->add($objects->getCount(), $folder);
     }
     // теперь извлекаем все файлы
     $query = new CQuery();
     $query->select("f.*")->from(TABLE_DOCUMENTS . " as f")->condition("f.nameFolder like 'gost%' and f.browserFile like '%" . $term . "%'")->order("f.browserFile asc");
     foreach ($query->execute()->getItems() as $ar) {
         $file = new CDocumentFile(new CDocumentActiveRecord($ar));
         if ($file->isFileExists()) {
             $objects->add($objects->getCount(), $file);
         }
     }
     foreach ($objects->getItems() as $obj) {
         $arr = array("id" => $obj->getId());
         if ($obj->isFolder()) {
             $arr["type"] = "folder";
             $arr["title"] = $obj->title;
         } else {
             $arr["type"] = "file";
             $arr["icon"] = $obj->getIconLink();
             $arr["title"] = $obj->browserFile;
             $arr["link"] = $obj->getFileLink();
         }
         $result[] = $arr;
     }
     echo json_encode($result);
 }
开发者ID:Rustam44,项目名称:ASUPortalPHP,代码行数:36,代码来源:CDocumentsController.class.php


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