Ejemplo n.º 1
0
 function execute(&$controller, &$request, &$user)
 {
     $this->attrs['title'] = 'Plnet > ' . msg('tags');
     $tag = $request->hasParameter('tag') ? $request->getParameter('tag') : null;
     if ($tag) {
         $entries = EntryUtils::get_entries_by_tagname($tag);
         foreach ($entries as $key => $entry) {
             $entry['tags'] = TagUtils::get_tags_by_entry_id($entry['id']);
         }
         $request->setAttribute('pager', ActionUtils::pager($entries));
         $request->setAttribute('tag', $tag);
     }
     return VIEW_INDEX;
 }
 function execute(&$controller, &$request, &$user)
 {
     $cc_name = $request->getAttribute('cc_name');
     $title = sprintf(msg('user list of this content category service'), msg($cc_name));
     $ms = MemberUtils::get_list_by_content_category_name($cc_name);
     foreach ((array) $ms as $member) {
         if ($member['show_profile']) {
             $feeds = FeedUtils::get_feeds_by_account($member['account']);
             $m = array('account' => $member['account'], 'profile_icon' => $member['photo'] ? SCRIPT_PATH . "photo.php?member_id={$member['id']}" : SCRIPT_PATH . 'images/profile_icon.jpg', 'self_introduction' => $member['self_introduction'], 'feeds' => $feeds);
             $members[] = $m;
         }
     }
     $request->setAttribute('title', $title);
     $request->setAttribute('pager', ActionUtils::pager($members, 50));
     return VIEW_SUCCESS;
 }
 /**
  * This method is called to perform validation
  *
  * @param string $context        A string representing the name of the context
  *                                 in which the validation occurs. For example: 'add', 'edit', 'delete', etc.
  * @param mixed  $arg, $arg, ... Using func_get_args() these arguments will be passed to the validator function
  *                                  invoked by this function.
  *
  * @return array an array of Errors (or empty array)
  */
 public function validateFor($context)
 {
     $this->errors = new Errors();
     // create camelized method name
     $methodResolved = ActionUtils::parseMethod($context);
     // check method exists
     if (!method_exists($this, $methodResolved)) {
         throw new Exception('Method [' . $methodResolved . '] does not exist on class [' . get_class($this) . ']');
     }
     $this->preValidate();
     // if(LOG_ENABLE) System::log(self::$logType, 'Executing method ['.$methodResolved.']');
     $arr = array_slice(func_get_args(), 1);
     // CALL THE METHOD
     call_user_func_array(array($this, $methodResolved), $arr);
     $this->postValidate();
     return $this->errors;
 }
Ejemplo n.º 4
0
 function execute(&$controller, &$request, &$user)
 {
     $this->attrs['title'] = "Plnet > " . msg('setting') . " > " . msg('footprint');
     $member = $user->getAttribute('member', GLU_NS);
     $owner_id = isset($member->id) ? $member->id : null;
     $fps = FootprintUtils::find_by_owner_id($owner_id);
     $footprints = array();
     foreach ($fps as $fp) {
         $fp['profile_icon'] = $fp['photo'] ? SCRIPT_PATH . "photo.php?member_id={$fp['id']}" : SCRIPT_PATH . 'images/profile_icon.jpg';
         $fp['name'] = $fp['nickname'] ? $fp['nickname'] : $fp['account'];
         $fp['link'] = SCRIPT_PATH . $fp['account'] . '/';
         $fp['formated_time'] = date(msg('entry date format'), $fp['created_on']);
         $footprints[] = $fp;
     }
     $request->setAttribute('pager', ActionUtils::pager($footprints, 50));
     return VIEW_SUCCESS;
 }
Ejemplo n.º 5
0
 function execute(&$controller, &$request, &$user)
 {
     $format = $request->hasParameter('format') ? $request->getParameter('format') : 'html';
     $limit = $format != 'html' ? PLNET_FEED_NUMBER : null;
     $this->attrs['title'] = 'Plnet > ' . msg('plnet list');
     $member = DB_DataObject::factory('member');
     $sql = 'SELECT m.id, m.account, m.photo,
         UNIX_TIMESTAMP(m.createdtime) AS createdtime,
         s.title, s.description
         FROM member m
         JOIN site s ON m.id = s.member_id
         ORDER BY createdtime DESC';
     if ($limit) {
         $sql .= " LIMIT {$limit}";
     }
     $member->query($sql);
     $members = array();
     while ($member->fetch()) {
         $feeds = FeedUtils::get_feeds_by_account($member->account);
         $m = array('account' => $member->account, 'profile_icon' => $member->photo ? SCRIPT_PATH . "photo.php?member_id={$member->id}" : SCRIPT_PATH . 'images/profile_icon.jpg', 'author' => $member->account, 'title' => $member->title, 'link' => SCRIPT_PATH . "{$member->account}/", 'date' => $member->createdtime, 'description' => $member->description, 'feeds' => $feeds);
         $members[] = $m;
     }
     $channel = array('title' => '新しいPlnet', 'link' => SCRIPT_PATH . 'list/', 'description' => '新しいPlnet');
     switch ($format) {
         case 'rss10':
             $writer =& new FeedWriter();
             $channel['uri'] = "{$channel['link']}rss";
             $writer->setChannel($channel);
             $writer->setItems($members);
             $writer->display($format);
             return VIEW_NONE;
         case 'rss20':
             $writer =& new FeedWriter();
             $channel['uri'] = "{$channel['link']}rss2";
             $writer->setChannel($channel);
             $writer->setItems($members);
             $writer->display($format);
             return VIEW_NONE;
         case 'html':
         default:
             $request->setAttribute('pager', ActionUtils::pager($members, 50));
             return VIEW_INDEX;
     }
 }
 /**
  * Invokes the datasource specified by {@link $datasource}.
  *
  * The {@link $datasource} can be split into controller and datasource
  * through ActionUtils::parseActionDatasource().
  *
  * @param string $datasource The datasource to invoke
  * @param array  $data       The data for the datasource
  * @param array  &$locals    The locals for the datasource
  *
  * @return mixed The data returned from the datasource (usually an array)
  */
 public function invokeDatasource($datasource, array &$preloadedData, array &$templateVariables)
 {
     list($controllerName, $datasource) = ActionUtils::parseActionDatasource($datasource);
     $controller = $this->getControllerByName($controllerName);
     $data = $controller->handleDatasource($controllerName, $datasource, $preloadedData, $templateVariables)->getData();
     return $data;
 }
 protected function handleFilter($filterCall, $params, $locals)
 {
     list($filtererName, $method) = ActionUtils::parseActionDatasource($filterCall, true);
     $filterer = $this->FilterManager->getFiltererByName($filtererName);
     $filterResult = $filterer->handleFilter($filtererName, $method, $params, $locals, array_merge($this->globals, $this->getConstants()));
     if (!$filterer->isAllowTemplateCode()) {
         $filterResult = preg_replace("/\\%([A-Za-z#][A-Za-z0-9\\-\\_\\:\\.\\[\\]\\=\\#\\~]+)\\%/", '%$1%', str_replace(array('{%', '%}'), array('{%', '%}'), $filterResult));
     }
     return $filterResult;
 }
 public function handleDatasource($name, $method, array $preloadedData, array &$templateVariables)
 {
     $this->name = $name;
     $datasource = ActionUtils::createActionDatasource($name, $method);
     // set the variables for use
     $this->templateVars =& $templateVariables;
     $this->currentDatasource = $datasource;
     // set the current datasource
     $this->currentActionOrDatasource = $datasource;
     $methodResolved = ActionUtils::parseMethod($method);
     $this->currentMethod = $methodResolved;
     //if(LOG_ENABLE) System::log(self::$logType, 'Datasource: ['.$datasource.']');
     // if we did an action and the datasource is already set, use it
     if (self::$actionBoundDatasource == $datasource) {
         return $this;
     }
     if (!method_exists($this, $methodResolved)) {
         throw new Exception('Method [' . $methodResolved . '] does not exist on class [' . get_class($this) . ']');
     }
     // clear the data first
     $this->setData(null);
     // set preloaded data (from Renderer)
     if (!empty($preloadedData)) {
         $this->setData($preloadedData);
     }
     $this->preDatasource();
     //if(LOG_ENABLE) System::log(self::$logType, 'Executing method ['.$methodResolved.']');
     $result = null;
     $result = $this->{$methodResolved}();
     if ($result == null) {
         $result = array();
     }
     // bind to datasource
     $this->setData($result);
     $this->postDatasource();
     return $this;
     // for chaining
 }
 /**
  * This function is used to handle the call to the filterer method.
  * It fires preHandle, the specified filterer method, then postHandle.
  *
  * It's this function that makes it required for all filterer classes to be a child
  * of this class (unless they implement their own version of course.)
  *
  * @param string $filtererName Name of the filter namespace, typically the class name
  * @param string $method       The filterer method to run
  * @param array  $params       An array of parameters for the filterer method
  * @param array  $locals       An array of locals
  * @param array  $globals      An array of globals
  *
  * @return string The result from the filterer method that will be inserted into the template.
  */
 public function handleFilter($filtererName, $method, $params, $locals, $globals)
 {
     $this->allowTemplateCode = false;
     $this->locals = $locals;
     $this->globals = $globals;
     $this->params = $params;
     //empty string given for method, use default method
     if (strlen($method) == 0 && $this->getDefaultMethod() != null) {
         $methodResolved = $this->getDefaultMethod();
     } else {
         if (strlen($method) > 0) {
             $methodResolved = ActionUtils::parseMethod($method);
         } else {
             throw new Exception('No filter method specified and default method does not exist on class [' . get_class($this) . ']');
         }
     }
     $this->currentMethod = $methodResolved;
     $this->currentFilter = $filtererName . (strlen($method) == 0 ? '' : '-' . $method);
     if (!method_exists($this, $methodResolved)) {
         throw new Exception('Method [' . $methodResolved . '] does not exist on class [' . get_class($this) . ']');
     }
     $this->preFilter($params);
     $result = $this->{$methodResolved}($params);
     $this->postFilter($params, $result);
     return $result;
 }
Ejemplo n.º 10
0
 public function setControls($params)
 {
     $cvars = array('view', 'view_page', 'view_handler', 'view_paging', 'view_nodebug', 'view_nocache', 'view_pushcache', 'view_rss_link', 'action', 'action_nonce', 'action_success_view', 'action_form_view', 'action_continue_view', 'action_new_view', 'action_cancel_view', 'action_confirm_delete_view', 'action_datasource', 'action_buffer');
     foreach ($params as $name => $value) {
         //			if(in_array($name, $cvars)) {
         $this->controls[$name] = $value;
         //			}
         if (substr($name, 0, 2) == 'b_') {
             if (substr($name, -2) == '_x' || substr($name, -2) == '_y') {
                 $name = substr($name, 0, -2);
             }
             $this->controls['action_button'] = substr($name, 2);
         }
         if (substr($name, 0, 2) == 'a_') {
             if (substr($name, -2) == '_x' || substr($name, -2) == '_y') {
                 $name = substr($name, 0, -2);
             }
             $this->controls['action_button'] = 'save';
             $this->controls['action_override_method'] = substr($name, 2);
         }
     }
     if (isset($this->controls['view_pushcache'])) {
         $_SERVER['REQUEST_URI'] = preg_replace('/\\?view_pushcache=([^\\&]+)\\&/', '?', $_SERVER['REQUEST_URI']);
         $_SERVER['REQUEST_URI'] = preg_replace('/\\?view_pushcache=([^\\&]+)/', '', $_SERVER['REQUEST_URI']);
         unset($_GET['view_pushcache']);
     }
     if (isset($this->controls['action_button'])) {
         $this->controls['action_executing'] = true;
         $this->controls['view_nocache'] = true;
     }
     if (isset($this->controls['action'])) {
         try {
             list($elem, $method) = ActionUtils::parseActionDatasource($this->controls['action']);
             $this->controls['action'] = ActionUtils::createActionDatasource($elem, $method);
             $this->controls['action_element'] = $elem;
             $this->controls['action_method'] = $method;
         } catch (ActionDatasourceException $ae) {
             unset($this->controls['action']);
             unset($this->controls['action_element']);
             unset($this->controls['action_method']);
         }
     }
     return $this;
 }