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


PHP Zend_Controller_Router_Rewrite::assemble方法代码示例

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


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

示例1: recentAction

 public function recentAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $this->_helper->verifyIdentity();
     $recent = new Ml_Model_Recent();
     if (!$registry->isRegistered("authedUserInfo")) {
         throw new Exception("Not authenticated.");
     }
     $userInfo = $registry->get("authedUserInfo");
     $uploads = $recent->contactsUploads($userInfo['id']);
     //send response
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("items");
     $doc->appendChild($rootElement);
     foreach ($uploads as $share) {
         $shareElement = $doc->createElement("item");
         $avatarInfo = unserialize($share['people.avatarInfo']);
         if (isset($avatarInfo['secret'])) {
             $iconSecret = $avatarInfo['secret'];
         } else {
             $iconSecret = '';
         }
         $shareData = array("type" => "file", "id" => $share['id']);
         foreach ($shareData as $name => $field) {
             $shareElement->appendChild($doc->newTextAttribute($name, $field));
         }
         $shareData = array("title" => $share['share.title'], "short" => $share['share.short'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $share['people.alias'], "share_id" => $share['id']), "sharepage_1stpage"));
         foreach ($shareData as $name => $field) {
             $shareElement->appendChild($doc->newTextElement($name, $field));
         }
         $filesizeElement = $doc->createElement("filesize");
         $filesizeElement->appendChild($doc->newTextAttribute("bits", $share['share.fileSize']));
         $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($share['share.fileSize'] / (1024 * 8))));
         $shareElement->appendChild($filesizeElement);
         $ownerElement = $doc->createElement("owner");
         $shareData = array("id" => $share['people.id'], "alias" => $share['people.alias'], "realname" => $share['people.name'], "iconsecret" => $iconSecret);
         foreach ($shareData as $name => $field) {
             $ownerElement->appendChild($doc->newTextAttribute($name, $field));
         }
         $shareElement->appendChild($ownerElement);
         $rootElement->appendChild($shareElement);
     }
     $this->_helper->printResponse($doc);
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:50,代码来源:ActivityController.php

示例2: infoAction

 public function infoAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $request = $this->getRequest();
     $params = $request->getParams();
     $people = Ml_Model_People::getInstance();
     $favorites = Ml_Model_Favorites::getInstance();
     $comments = Ml_Model_Comments::getInstance();
     $tags = Ml_Model_Tags::getInstance();
     $numbers = new Ml_Model_Numbers();
     $this->_helper->loadApiresource->share();
     $shareInfo = $registry->get("shareInfo");
     $userInfo = $people->getById($shareInfo['byUid']);
     $tagsList = $tags->getShareTags($shareInfo['id']);
     $countFavs = $favorites->count($shareInfo['id']);
     $countComments = $comments->count($shareInfo['id']);
     //begin of response
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("file");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $shareInfo['id']));
     $rootElement->appendChild($doc->newTextAttribute('secret', $shareInfo['secret']));
     $rootElement->appendChild($doc->newTextAttribute('download_secret', $shareInfo['download_secret']));
     $ownerElement = $doc->createElement("owner");
     $ownerData = array("id" => $userInfo['id'], "username" => $userInfo['alias'], "realname" => $userInfo['name']);
     foreach ($ownerData as $field => $data) {
         $ownerElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($ownerElement);
     $shareData = array("title" => $shareInfo['title'], "filename" => $shareInfo['filename'], "filetype" => $shareInfo['type'], "short" => $shareInfo['short'], "description" => $shareInfo['description_filtered'], "url" => "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias'], "share_id" => $shareInfo['id']), "sharepage_1stpage"), "dataurl" => $config['services']['S3']['sharesBucketAddress'] . $userInfo['alias'] . "/" . $shareInfo['id'] . "-" . $shareInfo['download_secret'] . "/" . $shareInfo['filename'], "shorturl" => $config['URLshortening']['addr'] . $numbers->base58Encode($shareInfo['id']), "comments" => $countComments, "favorites" => $countFavs);
     foreach ($shareData as $field => $data) {
         $rootElement->appendChild($doc->newTextElement($field, $data));
     }
     $filesizeElement = $doc->createElement("filesize");
     $filesizeElement->appendChild($doc->newTextAttribute("bits", $shareInfo['fileSize']));
     $filesizeElement->appendChild($doc->newTextAttribute("kbytes", ceil($shareInfo['fileSize'] / (1024 * 8))));
     $rootElement->appendChild($filesizeElement);
     $checksumElement = $doc->createElement("checksum");
     $checksumElement->appendChild($doc->newTextAttribute("hash", "md5"));
     $checksumElement->appendChild($doc->newTextAttribute("value", $shareInfo['md5']));
     $rootElement->appendChild($checksumElement);
     $visibilityElement = $doc->createElement("visibility");
     $visibilityElement->appendChild($doc->newTextAttribute("ispublic", "1"));
     $rootElement->appendChild($visibilityElement);
     $datesData = array("posted" => $shareInfo['uploadedTime'], "lastupdate" => $shareInfo['lastChange']);
     $datesElement = $doc->createElement("dates");
     foreach ($datesData as $field => $data) {
         $datesElement->appendChild($doc->newTextAttribute($field, $data));
     }
     $rootElement->appendChild($datesElement);
     $tagsElement = $doc->createElement("tags");
     foreach ($tagsList as $tag) {
         $tagElement = $doc->createElement("tag");
         $tagElement->appendChild($doc->newTextAttribute("id", $tag['id']));
         $tagElement->appendChild($doc->newTextAttribute("raw", $tag['raw']));
         $tagElement->appendChild($doc->createTextNode($tag['clean']));
         $tagsElement->appendChild($tagElement);
     }
     $rootElement->appendChild($tagsElement);
     $this->_helper->printResponse($doc);
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:67,代码来源:FilesController.php

示例3: assemble

 /**
  * Generates a URL path that can be used in URL creation, redirection, etc.
  *
  * @param  array $userParams Options passed by a user used to override parameters
  * @param  mixed $name The name of a Route to use
  * @param  bool $reset Whether to reset to the route defaults ignoring URL params
  * @param  bool $encode Tells to encode URL parts on output
  * @throws Zend_Controller_Router_Exception
  * @return string Resulting absolute URL path
  */
 public function assemble($userParams, $name = null, $reset = false, $encode = true)
 {
     if ($name == null) {
         try {
             $name = $this->getCurrentRouteName();
         } catch (Zend_Controller_Router_Exception $e) {
             $name = 'default';
         }
     }
     if ($name == 'default') {
         if ($this->_useDefaultRoutes) {
             $this->addDefaultRoutes();
         }
     }
     return parent::assemble($userParams, $name, $reset, $encode);
 }
开发者ID:rom1git,项目名称:Centurion,代码行数:26,代码来源:Rewrite.php

示例4: infoAction

 public function infoAction()
 {
     //@todo route: do it the right way!
     $router = new Zend_Controller_Router_Rewrite();
     $routeConfig = new Zend_Config_Ini(APPLICATION_PATH . '/configs/defaultRoutes.ini');
     $router->addConfig($routeConfig, 'routes');
     $registry = Zend_Registry::getInstance();
     $config = $registry->get("config");
     $request = $this->getRequest();
     $params = $request->getParams();
     $people = Ml_Model_People::getInstance();
     $profile = Ml_Model_Profile::getInstance();
     $share = Ml_Model_Share::getInstance();
     if (isset($params['username'])) {
         $userInfo = $people->getByUsername($params['username']);
     } else {
         if (isset($params['user_id'])) {
             $userInfo = $people->getById($params['user_id']);
         } else {
             if (isset($params['email'])) {
                 $userInfo = $people->getByEmail($params['email']);
                 if (!empty($userInfo) && $userInfo['private_email'] == true) {
                     $registry->set("notfound", true);
                     throw new Exception("User not found.");
                 }
             } else {
                 throw new Exception("No user params were given.");
             }
         }
     }
     if (empty($userInfo)) {
         $registry->set("notfound", true);
         throw new Exception("User not found.");
     }
     $profileInfo = $profile->getById($userInfo['id']);
     $doc = new Ml_Model_Dom();
     $doc->formatOutput = true;
     $rootElement = $doc->createElement("person");
     $doc->appendChild($rootElement);
     $rootElement->appendChild($doc->newTextAttribute('id', $userInfo['id']));
     $avatarInfo = unserialize($userInfo['avatarInfo']);
     if (isset($avatarInfo['secret'])) {
         $iconSecret = $avatarInfo['secret'];
     } else {
         $iconSecret = '';
     }
     $rootElement->appendChild($doc->newTextAttribute('iconsecret', $iconSecret));
     $userData = array("username" => $userInfo['alias'], "realname" => $userInfo['name']);
     if (!$userInfo['private_email']) {
         $userData["mbox_sha1sum"] = sha1("mailto:" . $userInfo['email']);
     }
     $userData["location"] = $profileInfo['location'];
     $userData["url"] = "http://" . $config['webhost'] . $router->assemble(array("username" => $userInfo['alias']), "filestream_1stpage");
     foreach ($userData as $field => $data) {
         $rootElement->appendChild($doc->newTextElement($field, $data));
     }
     $sharesCounter = $share->countOfUser($userInfo['id']);
     $sharesElement = $doc->createElement("files");
     $sharesCounterElement = $doc->createElement("count");
     $sharesCounterElement->appendChild($doc->createTextNode($sharesCounter));
     $sharesElement->appendChild($sharesCounterElement);
     $rootElement->appendChild($sharesElement);
     $this->_helper->printResponse($doc);
 }
开发者ID:henvic,项目名称:MediaLab,代码行数:64,代码来源:PeopleController.php


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