Example #1
0
 public static function parse_list($response)
 {
     $result = array();
     try {
         $atom = Atom::parse($response, new YouTubeDataMedia());
     } catch (Exception $e) {
         throw new Exception($response);
     }
     foreach ($atom->arEntry() as $entry) {
         $obj = new self();
         $links = $entry->link();
         if (isset($links[0])) {
             $obj->url($links[0]->href());
         }
         if (isset($links[3])) {
             $obj->mobile_url($links[3]->href());
         }
         if ($entry->content() instanceof AtomContent) {
             $obj->content($entry->content()->value());
         }
         $obj->title($entry->title());
         $obj->published($entry->published());
         $obj->updated($entry->updated());
         $obj->keyword($entry->extra()->keyword());
         $obj->duration($entry->extra()->duration());
         $obj->player($entry->extra()->player());
         $obj->category($entry->extra()->category());
         $obj->thumbnail($entry->extra()->thumbnail());
         $result[] = $obj;
     }
     return $result;
 }
Example #2
0
 public static function show($elements = null) {
   if ($user = site()->user() and $user->hasPanelAccess()) {
     $self = new self($elements);
     $bar  = '<div class="panelbar '.$self->position.'">'.$self->content().'</div>';
     $bar .= $self->css();
     return $bar;
   }
 }
Example #3
0
 public static function parse(Tag $entry)
 {
     $self = new self();
     $self->term($entry->f("category.param(term)"));
     $self->link($entry->f("link.param(href)"));
     $self->content($entry->f("content.value()"));
     $self->updated($entry->f("updated.value()"));
     $user = new MixiUser();
     $user->name($entry->f("author.name.value()"));
     $user->link($entry->f("author.uri.value()"));
     $self->author($user);
     return $self;
 }
Example #4
0
 public static function parse_list($response)
 {
     $result = array();
     $res = Text::parse_json($response);
     if (!isset($res["responseData"]["results"])) {
         throw new Exception("Invalid data");
     }
     foreach ($res["responseData"]["results"] as $re) {
         $obj = new self();
         $obj->cache_url($re["cacheUrl"]);
         $obj->url($re["unescapedUrl"]);
         $obj->title($re["titleNoFormatting"]);
         $obj->content($re["content"]);
         $result[] = $obj;
     }
     return $result;
 }
Example #5
0
 /**
  * Read template file into content string and return it
  *
  * @return string
  */
 public function content($parsePHP = true)
 {
     if (!$this->_templateContent) {
         $this->exists(true);
         $vfile = $this->path() . $this->fileName();
         // Include() and parse PHP code
         if ($parsePHP) {
             ob_start();
             // Use closure to get isolated scope
             $view = $this;
             $vars = $this->vars();
             $render = function ($templateFile) use($view, $vars) {
                 extract($vars);
                 require $templateFile;
                 return ob_get_clean();
             };
             $templateContent = $render($vfile);
         } else {
             // Just get raw file contents
             $templateContent = file_get_contents($vfile);
         }
         $templateContent = trim($templateContent);
         // Wrap template content in layout
         if ($this->layout()) {
             // Ensure layout doesn't get rendered recursively
             self::$_config['auto_layout'] = false;
             // New template for layout
             $layout = new self($this->layout());
             // Set layout path if specified
             if (isset(self::$_config['path_layouts'])) {
                 $layout->path(self::$_config['path_layouts']);
             }
             // Pass all locally set variables to layout
             $layout->set($this->_vars);
             // Set main yield content block
             $layout->set('yield', $templateContent);
             // Get content
             $templateContent = $layout->content($parsePHP);
         }
         $this->_templateContent = $templateContent;
     }
     return $this->_templateContent;
 }
Example #6
0
 protected function render(array $params)
 {
     $type = key($params);
     switch ($type) {
         case 'template':
             $file = array_shift($params);
             $template = new self(['file' => $file]);
             $template->renderContent();
             return $template->content();
             break;
     }
 }
Example #7
0
 /**
  * Create a sms instance send SMS,
  * your can also set SMS templates or content at the same time.
  *
  * @param mixed $agentName
  * @param mixed $tempId
  *
  * @return Sms
  */
 public static function make($agentName = null, $tempId = null)
 {
     $sms = new self();
     $sms->smsData['type'] = self::TYPE_SMS;
     if (is_array($agentName)) {
         $sms->template($agentName);
     } elseif ($agentName && is_string($agentName)) {
         if ($tempId === null) {
             $sms->content($agentName);
         } elseif (is_string($tempId) || is_int($tempId)) {
             $sms->template($agentName, "{$tempId}");
         }
     }
     return $sms;
 }
Example #8
0
File: Sms.php Project: jgglg/phpsms
 /**
  * create sms instance and set templates
  *
  * @param mixed $agentName
  * @param mixed $tempId
  *
  * @return Sms
  */
 public static function make($agentName = null, $tempId = null)
 {
     $sms = new self();
     if (is_array($agentName)) {
         $sms->template($agentName);
     } elseif ($agentName && is_string($agentName)) {
         if ($tempId === null) {
             $sms->content($agentName);
         } elseif (is_string("{$tempId}")) {
             $sms->template($agentName, $tempId);
         }
     }
     return $sms;
 }