Exemplo n.º 1
0
 /**
  * Std. getter. Returns a property of the object or the default value if the property is not set.
  * @param string $attr
  * @param mixed $default
  * @param boolean $object - return object instead of data
  * @return mixed
  */
 public function get($attr, $default = null, $object = false)
 {
     if (strstr($attr, 'field_')) {
         if (isset($this->fieldsNids[trim($attr)])) {
             return $object ? $this->fieldsNids[trim($attr)] : $this->fieldsNids[trim($attr)]->data();
         }
     } else {
         return parent::get($attr, $default);
     }
 }
Exemplo n.º 2
0
 /**
  * Adds object to the pathway
  * @param SPDBObject $obj
  * @param array $site
  * @return void
  */
 public function &addObjToPathway($obj, $site = array())
 {
     if (defined('SOBI_ADM_PATH')) {
         return true;
     }
     $menu = JSite::getMenu()->getActive()->query;
     $sid = isset($menu['sid']) ? $menu['sid'] : 0;
     $resetPathway = false;
     if ($obj->get('oType') == 'entry') {
         $id = SPRequest::int('pid');
         /** if the entry isn't linked directly in the menu */
         if (!($obj->get('id') == $sid)) {
             /* if we didn't entered this entry via category */
             if (!$id || $id == Sobi::Section() || Sobi::Cfg('entry.primary_path_always')) {
                 $id = $obj->get('parent');
                 $resetPathway = true;
             }
         } else {
             /** ok - here is the weird thing:
              * When it is accessed via menu we have to force cache to create another version
              * because the pathway is stored in the cache
              * @todo find better solution for it
              */
             $mid = true;
             SPFactory::registry()->set('cache_view_recreate_request', $mid)->set('cache_view_add_itemid', JSite::getMenu()->getActive()->id);
             return $this;
         }
     } else {
         $id = $obj->get('id');
     }
     $path = SPFactory::cache()->getVar('parent_path', $id);
     if (!$path) {
         $path = SPFactory::config()->getParentPath($id, true, false, true);
         SPFactory::cache()->addVar($path, 'parent_path', $id);
     }
     if (count($path)) {
         /* skip everything above the linked sid */
         $rpath = array_reverse($path);
         $path = array();
         foreach ($rpath as $part) {
             if ($part['id'] == $sid) {
                 break;
             }
             $path[] = $part;
         }
         $path = array_reverse($path);
         /* ^^ skip everything above the linked sid */
     }
     $title = array();
     // if there was an active menu - add its title to the browser title as well
     if ($sid) {
         $title[] = JFactory::getDocument()->getTitle();
     }
     /**
      * Mon, Jul 16, 2012
      * I would relay like to know why I've added the "htmlentities" call here.
      * The second param of the 'addItem' method is URL so there should be definitely no such thing
      * Related to Bug #692
      */
     if (count($path)) {
         if ($resetPathway) {
             /** we have to reset the J! pathway in case:
              *  - we are entering an entry and we want to show the pathway corresponding to the main parent if of the entry
              *    but we have also an Itemid and Joomla! set already the pathway partialy so we need to override it
              *    It wouldn't be normally a problem but when SEF is enabled we do not have the pid so we don't know how it has been enetered
              */
             JFactory::getApplication()->getPathway()->setPathway(array());
         }
         foreach ($path as $data) {
             if (!(isset($data['name']) || isset($data['id'])) || !$data['id']) {
                 continue;
             }
             $title[] = $data['name'];
             $this->addToPathway($data['name'], self::url(array('title' => Sobi::Cfg('sef.alias', true) ? $data['alias'] : $data['name'], 'sid' => $data['id'])));
         }
     }
     if ($obj->get('oType') == 'entry') {
         $this->addToPathway($obj->get('name'), self::url(array('task' => 'entry.details', 'title' => Sobi::Cfg('sef.alias', true) ? $obj->get('nid') : $obj->get('name'), 'sid' => $obj->get('id'))));
         $title[] = $obj->get('name');
     }
     //		if ( count( $site ) && $site[ 0 ] ) {
     //			$title[ ] = Sobi::Txt( 'SITES_COUNTER', $site[ 1 ], $site[ 0 ] );
     //		}
     SPFactory::header()->addTitle($title, $site);
     return $this;
 }
Exemplo n.º 3
0
 /**
  * Gets meta keys and met description from the given object
  *  and adds to the site header
  * @param SPDBObject $obj
  * @return SPHeader
  */
 public function &objMeta($obj)
 {
     if ($obj->get('metaDesc')) {
         $this->addDescription($obj->get('metaDesc'));
     }
     if ($obj->get('metaKeys')) {
         $this->addKeyword($obj->get('metaKeys'));
     }
     if ($obj->get('metaAuthor')) {
         $this->addAuthor($obj->get('metaAuthor'));
     }
     if ($obj->get('metaRobots')) {
         $this->addRobots($obj->get('metaRobots'));
     }
     if ($obj->get('oType') != 'section' && Sobi::Cfg('meta.always_add_section')) {
         $this->objMeta(SPFactory::currentSection());
     }
     if ($obj->get('oType') == 'entry') {
         $fields = $obj->getFields();
         if (count($fields)) {
             foreach ($fields as $field) {
                 $this->addDescription($field->metaDesc());
                 $this->addKeyword($field->metaKeys());
             }
         }
     }
     return $this;
 }