当前位置: 首页>>代码示例>>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;未经允许,请勿转载。