當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Eva\Api類代碼示例

本文整理匯總了PHP中Eva\Api的典型用法代碼示例。如果您正苦於以下問題:PHP Api類的具體用法?PHP Api怎麽用?PHP Api使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Api類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: indexAction

 public function indexAction()
 {
     $serviceKey = $this->params()->fromQuery('service');
     $serviceType = $this->params()->fromQuery('type');
     $userId = $this->params()->fromQuery('uid');
     $serviceKey = ucfirst(strtolower($serviceKey));
     $serviceType = ucfirst(strtolower($serviceType));
     $this->changeViewModel('json');
     $itemModel = Api::_()->getModel('Oauth\\Model\\Accesstoken');
     $dataClass = $itemModel->getItem()->getDataClass();
     $item = $dataClass->where(function ($where) use($serviceKey, $serviceType, $userId) {
         $where->equalTo('adapterKey', strtolower($serviceKey));
         $where->equalTo('tokenStatus', 'active');
         $where->equalTo('version', $serviceType);
         $where->equalTo('user_id', $userId);
         return $where;
     })->find('one');
     $item = (array) $item;
     if (!$item) {
         return new JsonModel();
     }
     $webserice = WebserviceFactory::factory($serviceType . $serviceKey, $item, $this->getServiceLocator());
     $adapter = $webserice->getAdapter();
     $userApi = $adapter->uniformApi('User');
     $userId = $item['remoteUserId'];
     $user = $userApi->setUserId($userId)->getData();
     //$json = $userApi->getLastRawResponse();
     //p($userApi->getAdapter()->getClient()->getRequest()->toString());
     //p($userApi->getAdapter()->getClient()->getResponse()->getBody());
     return new JsonModel(array('data' => $user));
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:31,代碼來源:UserController.php

示例2: restGetRemove

 public function restGetRemove()
 {
     $id = $this->params('id');
     $itemModel = Api::_()->getModel('User\\Model\\User');
     $item = $itemModel->getUser($id);
     return array('callback' => $this->params()->fromQuery('callback'), 'item' => $item);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:7,代碼來源:RemoveController.php

示例3: upgradeRoleUser

 public function upgradeRoleUser($userId, $roleKey, $days)
 {
     $roleModel = Api::_()->getModel('User\\Model\\Role');
     $role = $roleModel->getRole($roleKey);
     if (!isset($role['id'])) {
         return array();
     }
     $roleUser = $this->getRoleUser($userId, $role['id']);
     $now = \Eva\Date\Date::getNow();
     if (!isset($roleUser['user_id'])) {
         $data['user_id'] = $userId;
         $data['role_id'] = $role['id'];
         $data['status'] = 'active';
         $data['activeTime'] = $now;
         $data['expiredTime'] = \Eva\Date\Date::getFuture(3600 * 24 * $days, $now, 'Y-m-d H:i:s');
         $this->setItem($data)->createRoleUser();
     } else {
         $roleUser['status'] = 'active';
         if ($roleUser['expiredTime'] > $now) {
             $roleUser['expiredTime'] = \Eva\Date\Date::getFuture(3600 * 24 * $days, $roleUser['expiredTime'], 'Y-m-d H:i:s');
         } else {
             $roleUser['expiredTime'] = \Eva\Date\Date::getFuture(3600 * 24 * $days, $now, 'Y-m-d H:i:s');
             $roleUser['activeTime'] = $now;
         }
         $roleUser->saveRoleUser();
     }
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:27,代碼來源:RoleUser.php

示例4: restPostSettingComponent

 public function restPostSettingComponent()
 {
     $postData = $this->getRequest()->getPost();
     $componentName = $postData['name'];
     $view = array();
     if (!$componentName) {
         return $view;
     }
     $api = Api::_();
     $config = $api->getConfig();
     if (!isset($config['page_components'][$componentName]) || !$config['page_components'][$componentName]) {
         return $view;
     }
     $component = $config['page_components'][$componentName];
     $path = $api->getModulePath($component['module']);
     $filepath = $path . DIRECTORY_SEPARATOR . 'view' . DIRECTORY_SEPARATOR . $component['path'] . '.phtml';
     if (file_exists($filepath) && is_writable($filepath)) {
         $handle = fopen($filepath, 'wa');
         fwrite($handle, $postData['content']);
         fclose($handle);
         $this->flashMessenger()->addMessage('file-edit-succeed');
         return $this->redirect()->toUrl('/admin/core/setting/component/' . $componentName);
     } else {
         if (!file_exists($filepath)) {
             $view['flashMesseger'] = array('file-not-exist');
         } else {
             $view['flashMesseger'] = array('file-not-writable');
         }
     }
     $view['component'] = $component;
     return $view;
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:32,代碼來源:SettingController.php

示例5: indexAction

 public function indexAction()
 {
     $serviceKey = $this->params()->fromQuery('service');
     $serviceType = $this->params()->fromQuery('type');
     $userId = $this->params()->fromQuery('uid');
     $serviceKey = ucfirst(strtolower($serviceKey));
     $serviceType = ucfirst(strtolower($serviceType));
     $this->changeViewModel('json');
     $itemModel = Api::_()->getModel('Oauth\\Model\\Accesstoken');
     $dataClass = $itemModel->getItem()->getDataClass();
     $item = $dataClass->where(function ($where) use($serviceKey, $serviceType, $userId) {
         $where->equalTo('adapterKey', strtolower($serviceKey));
         $where->equalTo('tokenStatus', 'active');
         $where->equalTo('version', $serviceType);
         $where->equalTo('user_id', $userId);
         return $where;
     })->find('one');
     $item = (array) $item;
     if (!$item) {
         return new JsonModel();
     }
     $fileModel = Api::_()->getModel('File\\Model\\File');
     $file = $fileModel->getFile(24, array('self' => array('*', 'getThumb()', 'getFullPath()')));
     $webserice = WebserviceFactory::factory($serviceType . $serviceKey, $item, $this->getServiceLocator());
     $adapter = $webserice->getAdapter();
     $albumApi = $adapter->uniformApi('Album');
     $albumApi->setUserId($item['remoteUserId']);
     $albumApi->setAlbumId('5819073682310479025');
     //$data = $albumApi->getAlbumList();
     $file = $albumApi->uploadPhoto($file);
     return new JsonModel(array('file' => $file));
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:32,代碼來源:AlbumController.php

示例6: restPostTestdataPosts

 public function restPostTestdataPosts()
 {
     $request = $this->getRequest();
     $postData = $request->getPost();
     $dataArray = MultiForm::getPostDataArray($postData);
     $itemModel = Api::_()->getModel('Blog\\Model\\Category');
     $postModel = Api::_()->getModel('Blog\\Model\\Post');
     $content = "國際在線專稿:據英國廣播公司8月10日報道,71歲的巴西球王貝利近日在英國倫敦觀看奧運會比賽。貝利接受媒體采訪時表示,他認為倫敦奧運會非常成功,而作為下屆奧運會舉辦國,巴西還未做好準備,恐難超越倫敦奧運會。\n巴西將在2014年舉辦世界杯,2年後又將迎來41屆夏季奧運會。貝利說,“當前事情看起來不大妙,我們的建築項目還有些小問題。”他表示,交通和傳媒方麵可能存在最大的問題,希望屆時能順利解決。距離舉辦巴西世界杯隻有兩年時間了,貝利似乎對巴西的舉辦能力缺乏信心。他說,“我已經和總統羅塞夫就此事討論過,她說會盡最大努力籌備組織奧運會,但我們還沒有真正準備好。”\n這位71歲的足球先生、足球運動的世界代言人表示,希望首次舉辦奧運會將為巴西帶來深厚的影響,但巴西也應該交給世界一份滿意的答卷。\n當被問及牙買加田徑運動員“閃電”博爾特是否像他和拳王阿裏一樣,具備成為最偉大的運動員的資格,他說,“當然,這毫無疑問。”----------------";
     foreach ($dataArray as $key => $array) {
         if ($array['order'] <= 0 || !$array['id']) {
             continue;
         }
         $categoryinfo = $itemModel->setItemParams($array['id'])->getCategory();
         if (!$categoryinfo) {
             continue;
         }
         for ($i = 1; $i <= $array['order']; $i++) {
             $postData = array('title' => $categoryinfo['categoryName'] . "-測試數據-" . $i, 'Text' => array('content' => $content), 'status' => 'published', 'codeType' => 'markdown', 'visibility' => 'public', 'commentStatus' => 'open', 'commentType' => 'local', 'CategoryPost' => array('category_id' => $array['id'], 'post_id' => 0));
             $form = new \Blog\Form\PostForm();
             $subForms = array('Text' => array('Blog\\Form\\TextForm'), 'CategoryPost' => array('Blog\\Form\\CategoryPostForm'), 'FileConnect' => array('File\\Form\\FileConnectForm'));
             $form->setSubforms($subForms)->init();
             $form->setData($postData)->enableFilters();
             if ($form->isValid()) {
                 $postData = $form->getData();
                 $postData = $form->fieldsMap($postData, true);
                 $postId = $postModel->setSubItemMap($subForms)->setItem($postData)->createPost();
             } else {
             }
         }
     }
     $this->redirect()->toUrl('/scaffold/testdata/posts/');
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:32,代碼來源:TestdataController.php

示例7: setParameters

 public function setParameters(Parameters $params)
 {
     $eventsUsersTable = Api::_()->getDbTable('Event\\DbTable\\EventsUsers');
     $eventsUsersTableName = $eventsUsersTable->initTableName()->getTable();
     if ($params->inEvent) {
         $this->join($eventsUsersTableName, "id = {$eventsUsersTableName}.user_id");
         /*
                     $this->initialize();
                     $select = $this->getSelect();
                     $inSelect = new Select($eventsUsersTableName);
                     $inSelect->columns(array('user_id'));
                     $select->where->in('id', $inSelect);
                     $this->setSelect($select);
         */
         if ($params->eventRole) {
             $this->where(array("{$eventsUsersTableName}.role" => $params->eventRole));
         }
     }
     if ($params->order == 'eventcountdesc') {
         $this->columns(array('*', 'EventCount' => new Expression("count(event_id)")));
         $this->group("{$eventsUsersTableName}.user_id");
         $this->order('EventCount DESC');
         unset($params->order);
     }
     return parent::setParameters($params);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:26,代碼來源:Users.php

示例8: restPutFormHtml

 public function restPutFormHtml()
 {
     $request = $this->getRequest();
     $postData = $request->getPost();
     $mainForm = $postData->form;
     $form = Api::_()->getForm($mainForm);
     $elements = $form->getMergedElements();
     $subFormString = $postData->subform;
     $subFormElements = array();
     if ($subFormString) {
         $subForms = explode(',', $subFormString);
         foreach ($subForms as $subForm) {
             $form = Api::_()->getForm($subForm);
             $subFormElements[$subForm] = $form->getMergedElements();
         }
     }
     $generator = new \Scaffold\Model\FormHtmlGenerator();
     $generator->setElements($elements);
     $subFormElements ? $generator->setSubFormElements($subFormElements) : null;
     $generator->setFormClassName($mainForm);
     list($elements, $subForms) = $generator->convertToFormHtml();
     $subFormsCode = $generator->printCode($subForms);
     $formClassName = $generator->getFormClassName();
     return array('formClassName' => $formClassName, 'elements' => $elements, 'subFormsCode' => $subFormsCode);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:25,代碼來源:ItemController.php

示例9: restGetRemove

 public function restGetRemove()
 {
     $id = $this->params('id');
     $itemModel = Api::_()->getModel('Notification\\Model\\Notification');
     $item = $itemModel->getNotification($id)->toArray();
     return array('callback' => $this->params()->fromQuery('callback'), 'item' => $item);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:7,代碼來源:RemoveController.php

示例10: setParameters

 public function setParameters(Parameters $params)
 {
     $groupsPostsTable = Api::_()->getDbTable('Group\\DbTable\\GroupsPosts');
     $groupsPostsTableName = $groupsPostsTable->initTableName()->getTable();
     $groupsCategoriesTable = Api::_()->getDbTable('Group\\DbTable\\CategoriesGroups');
     $groupsCategoriesTableName = $groupsCategoriesTable->initTableName()->getTable();
     if ($params->group_id || $params->groupCategory) {
         $params->inGroup = true;
     }
     if ($params->inGroup) {
         $groupId = $params->group_id;
         $categoryId = $params->groupCategory;
         $this->where(function ($where) use($groupsPostsTableName, $groupsCategoriesTableName, $groupId, $categoryId) {
             $select = new Select($groupsPostsTableName);
             $select->columns(array('post_id'));
             if ($groupId) {
                 $select->where(array('group_id' => $groupId));
             }
             if ($categoryId) {
                 $cateSelect = new Select($groupsCategoriesTableName);
                 $cateSelect->columns(array('group_id'));
                 $cateSelect->where(array('category_id' => $categoryId));
                 $select->where(function ($where) use($cateSelect) {
                     $where->in('group_id', $cateSelect);
                     return $where;
                 });
             }
             $where->in('id', $select);
             return $where;
         });
     }
     return parent::setParameters($params);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:33,代碼來源:Posts.php

示例11: getEventCalendar

 public function getEventCalendar(array $params = array(), $items = array())
 {
     $calendar = new CalendarLib($params);
     $calendarArray = $calendar->toArray();
     $query = array('afterStartDay' => $calendarArray['beginDay'], 'beforeStartDay' => $calendarArray['finishDay'], 'noLimit' => true);
     if (!$items) {
         $itemModel = Api::_()->getModel('Event\\Model\\Event');
         $this->eventList = $items = $itemModel->setItemList($query)->getEventdataList();
         $items = $items ? $items->toArray() : array();
     }
     if (count($items) == 0) {
         return $calendarArray;
     }
     foreach ($calendarArray['days'] as $weekKey => $weekArray) {
         foreach ($weekArray as $dayKey => $day) {
             foreach ($items as $key => $event) {
                 if ($day['datedb'] == $event['startDay']) {
                     $calendarArray['days'][$weekKey][$dayKey]['Events'][] = $event;
                     unset($items[$key]);
                 }
             }
         }
     }
     return $calendarArray;
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:25,代碼來源:Calendar.php

示例12: restIndexQueue

 public function restIndexQueue()
 {
     $config = Api::_()->getConfig();
     $defaultQueues = $config['queue']['default_queues'];
     $queues = array_merge($defaultQueues, \Resque::queues());
     $queues = array_unique($queues);
     foreach ($queues as $key => $queue) {
         $queues[$key] = array('name' => $queue, 'size' => \Resque::size($queue));
     }
     $pslist = $this->getSystemProcessList('ps ux | grep "php ' . realpath(EVA_ROOT_PATH . '/workers') . '" | grep -v grep');
     foreach ($queues as $key => $queue) {
         $workerCount = 0;
         foreach ($pslist as $psKey => $ps) {
             $offset = strlen($ps['COMMAND']) - strlen($queue['name']);
             if ($offset === strrpos($ps['COMMAND'], $queue['name'])) {
                 $workerCount++;
                 unset($pslist[$psKey]);
             }
         }
         $queues[$key]['workers'] = $workerCount;
     }
     $publicWorkerCount = count($pslist);
     $return = array('items' => $queues, 'publicWorkerCount' => $publicWorkerCount);
     if ($this->params()->fromQuery('format') == 'json') {
         $this->changeViewModel('json');
         return new JsonModel($return);
     }
     return $return;
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:29,代碼來源:QueueController.php

示例13: indexAction

 public function indexAction()
 {
     $user = Auth::getLoginUser();
     if (isset($user['isSuperAdmin']) || !$user) {
         exit;
     }
     $callback = $this->params()->fromQuery('r');
     $service = $this->params()->fromQuery('service');
     $emails = $this->params()->fromPost('email');
     if (!$emails) {
         exit;
     }
     $config = $this->getServiceLocator()->get('config');
     $helper = $this->getEvent()->getApplication()->getServiceManager()->get('viewhelpermanager')->get('serverurl');
     $url = $helper() . '/register/';
     if (!isset($config['contacts']['invite_mail'])) {
         exit;
     }
     $inviteModel = Api::_()->getModel('Contacts\\Model\\Invite');
     $inviteModel->setUser($user);
     $inviteModel->setRegUrl($url);
     $params['emails'] = $emails;
     $params['subject'] = $config['contacts']['invite_mail']['subject'];
     $params['template'] = $config['contacts']['invite_mail']['template'];
     $params['templatePath'] = $config['contacts']['invite_mail']['templatePath'];
     $inviteModel->sendInvite($params);
     foreach ($emails as $email) {
         $this->removeContacts($service, $email);
     }
     return $this->redirect()->toUrl($callback);
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:31,代碼來源:InviteController.php

示例14: syncAction

 public function syncAction()
 {
     $serviceKey = $this->params()->fromQuery('service');
     $serviceType = $this->params()->fromQuery('type');
     $content = $this->params()->fromQuery('content');
     $user = \Core\Auth::getLoginUser();
     $userId = $user['id'];
     $serviceKey = ucfirst(strtolower($serviceKey));
     $serviceType = ucfirst(strtolower($serviceType));
     $this->changeViewModel('json');
     if (!$userId || !$content) {
         return new JsonModel();
     }
     $itemModel = Api::_()->getModel('Oauth\\Model\\Accesstoken');
     $dataClass = $itemModel->getItem()->getDataClass();
     $item = $dataClass->where(function ($where) use($serviceKey, $serviceType, $userId) {
         $where->equalTo('adapterKey', strtolower($serviceKey));
         $where->equalTo('tokenStatus', 'active');
         $where->equalTo('version', $serviceType);
         $where->equalTo('user_id', $userId);
         return $where;
     })->find('one');
     $item = (array) $item;
     if (!$item) {
         return new JsonModel();
     }
     $webserice = WebserviceFactory::factory($serviceType . $serviceKey, $item, $this->getServiceLocator());
     $adapter = $webserice->getAdapter();
     $feedApi = $adapter->uniformApi('Feed');
     $feedApi->setUserId($item['remoteUserId']);
     $feed = $feedApi->createFeed(array('content' => $content));
     return new JsonModel(array('data' => $feed));
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:33,代碼來源:FeedController.php

示例15: setParameters

 public function setParameters(Parameters $params)
 {
     if ($params->page) {
         $this->enableCount();
         $this->page($params->page);
     }
     if ($params->noLimit) {
         $this->disableLimit();
     }
     if ($params->rows) {
         $this->limit((int) $params->rows);
     }
     if ($params->order == 'postcountdesc' || $params->order == 'postcountasc') {
         $postTagTable = Api::_()->getDbTable('Blog\\DbTable\\TagsPosts');
         $postTagTableName = $postTagTable->initTableName()->getTable();
         $this->join($postTagTableName, "id = {$postTagTableName}.tag_id");
         $this->columns(array('*', 'PostCount' => new Expression("count(post_id)")));
         $this->group('tag_id');
     }
     $orders = array('idasc' => 'id ASC', 'iddesc' => 'id DESC', 'nameasc' => 'tagName ASC', 'namedesc' => 'tagName DESC', 'postcountasc' => 'PostCount ASC', 'postcountdesc' => 'PostCount DESC');
     if ($params->order) {
         $order = $orders[$params->order];
         if ($order) {
             $this->order($order);
         }
     }
     return $this;
 }
開發者ID:ahyswang,項目名稱:eva-engine,代碼行數:28,代碼來源:Tags.php


注:本文中的Eva\Api類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。