======================================
 permalink
======================================
507258
def permalink
      return nil if data.nil? || data['permalink'].nil?
      
      if site.config['relative_permalinks']
        File.join(@dir,  data['permalink'])
      else
        # Look if there's a permalink overwrite specified for this lang
        data['permalink_'+site.config['lang']] || data['permalink']
      end
      
    end
304316
protected function _makeLink($sLink, $sParams)
    {
        if ($sParams) {
            $sLink .= ((strpos($sLink, '?') !== false) ? '&amp;' : '?') . $sParams;
        }

        return $sLink;
    }
834843
public function onWpLoaded()
    {
        if ($this->c::isCli()) {
            return; // Not applicable.
        }
        $WP_Rewrite = $GLOBALS['wp_rewrite'];

        if (!empty($_REQUEST[$this->var])) {
            $transient_hash = (string) $_REQUEST[$this->var];
        } elseif (mb_stripos($_SERVER['REQUEST_URI'] ?? '', '/'.$this->slug.'/') !== false && $WP_Rewrite->using_mod_rewrite_permalinks()) {
            $base_path = $this->c::mbRTrim((string) $this->c::parseUrl(home_url('/'), PHP_URL_PATH), '/');
            $path      = $base_path ? mb_substr($this->c::currentPath(), mb_strlen($base_path)) : $this->c::currentPath();

            if ($path && preg_match('/^\/'.$this->c::escRegex($this->slug).'\/(?<transient_hash>[^\/]+)(?:\/|$)/ui', $path, $_m)) {
                $transient_hash = $_m['transient_hash'];
            } else {
                return; // Not appplicable; i.e., unable to find transient hash in path.
            }
        } else {
            return; // Not applicable.
        }
        if (!($long_url = $this->s::getTransient('', $transient_hash))) {
            $this->s::dieInvalid(__('Sorry, link expired.', 'wp-sharks-core'));
        }
        wp_redirect($long_url, 301).exit(); // Stop on redirection.
    }
1350731
def add_permalink_methods(content_inst):
    '''
    
    '''
    for permalink_method in PERMALINK_METHODS:
        setattr(
            content_inst,
            permalink_method.__name__,
            permalink_method.__get__(content_inst, content_inst.__class__))
34652
public function index() {        
        $tree = Globals::getTree();
        $controller = new PageController();
        $controller
        ->setPageTitle(I18N::translate('Certificate'))
        ->restrictAccess(
            $this->module->getSetting('MAJ_SHOW_CERT', Auth::PRIV_HIDE) >= Auth::accessLevel($tree)
        );
        
        $cid = Filter::get('cid');
        
        $certificate = null;
        if(!empty($cid) && strlen($cid) > 22){
            $certificate = Certificate::getInstance($cid, $tree, null, $this->provider);
        }
        
        $data = new ViewBag();
        $data->set('title', $controller->getPageTitle());
        
        $data->set('has_certif', false);
        if($certificate) {
            $controller->restrictAccess($certificate->canShow());
            $data->set('title', $certificate->getTitle());
            $data->set('has_certif', true);
            $data->set('certificate', $certificate);
            
            $data->set(
                'url_certif_city', 
                'module.php?mod=' . Constants::MODULE_MAJ_CERTIF_NAME . 
                    '&mod_action=Certificate@listAll' .
                    '&ged=' . $tree->getNameUrl() .
                    '&city=' . Functions::encryptToSafeBase64($certificate->getCity())
            );
            
            $controller->addInlineJavascript('
                jQuery("#certificate-tabs").tabs();
			    jQuery("#certificate-tabs").css("visibility", "visible");    
            ');
            
            $data->set('has_linked_indis', false);
            $data->set('has_linked_fams', false);
            
            $linked_indis = $certificate->linkedIndividuals();
            $linked_fams = $certificate->linkedFamilies();
                        
            if($linked_indis && count($linked_indis) > 0) {
                $data->set('has_linked_indis', true);
                $data->set('linked_indis', $linked_indis);
            }
            
            if(!empty($linked_fams)) {
                $data->set('has_linked_fams', true);
                $data->set('linked_fams', $linked_fams);
            }
        }
        
        ViewFactory::make('Certificate', $this, $controller, $data)->render();
    }
337971
public function appendStdLink($sAddParams, $iLang = null)
    {
        if ($sAddParams) {
            if ($iLang === null) {
                $iLang = $this->getLanguage();
            }

            $this->_aStdAddParams[$iLang] = isset($this->_aStdAddParams[$iLang]) ? $this->_aStdAddParams[$iLang] . "&amp;" : "";
            $this->_aStdAddParams[$iLang] .= $sAddParams;
        }
    }
919839
function checkLink()
    {
        if (!isset($_POST['link'])) {
            $this->sendError();
        }

        $link = strtolower(str_replace([" ",'"',"'",';','.',','], ["-",""], preg_replace("/&([a-z])[a-z]+;/i", "$1", htmlentities(trim($_POST['link'])))));

        $base = new Model\Base;
        $status = $base->checkLink($link, $_POST['aID']) === false ? 'ok' : 'error';

        $this->send(['status'=>$status,'link'=>$link]);
    }
542301
def check_meta_permalink
      candidate = (self.meta_permalink ? self.meta_permalink : self.title.parameterize)
      accepted = nil
      counter = 0

      while accepted.nil?
        if LatoBlog::Tag.find_by(meta_permalink: candidate)
          counter += 1
          candidate = "#{candidate}-#{counter}"
        else
          accepted = candidate
        end
      end

      self.meta_permalink = accepted
    end
1338099
def obtain_the_permalink(check = nil, render_inline = true)
      site_url = Setting.get('site_url')
      post = obtain_record(check)

      return '' if post.blank?

      article_url = Setting.get('articles_slug')

      url =
        if post.post_type == 'post'
           site_url("#{article_url}#{post.structured_url}")
        else
          site_url("#{post.structured_url}")
        end

      if render_inline
        render :inline => url
      else
        url
      end

    end
863314
function renderNav($prefix = '<span class="page_link">', $suffix = '</span>') {
        if ($this->total_rows == 0)
            return FALSE;
         
        $batch = ceil($this->page / $this->links_per_page );
        $end = $batch * $this->links_per_page;
        if ($end == $this->page) {
        //$end = $end + $this->links_per_page - 1;
        //$end = $end + ceil($this->links_per_page/2);
        }
        if ($end > $this->max_pages) {
            $end = $this->max_pages;
        }
        $start = $end - $this->links_per_page + 1;
        $links = '';
         
        for($i = $start; $i <= $end; $i ++) {
            if ($i == $this->page) {
                $links .= $prefix . " $i " . $suffix;                                       
            } else {
                $links .= " <a href='javascript:void(0);' OnClick='getdata( $i )' title='Outra página'>$i</a> ";
            }
        }
         
        return $links;
    }
562324
public function index()
    {
        //  Meta & Breadcrumbs
        $this->data['page']->title            = APP_NAME . ' Blog';
        $this->data['page']->seo->description = '';
        $this->data['page']->seo->keywords    = '';

        // --------------------------------------------------------------------------

        //  Handle pagination
        $page      = $this->uri->rsegment(3);
        $perPage  = appSetting('home_per_page', 'blog-' . $this->oBlog->id);
        $perPage  = $perPage ? $perPage : 10;

        $this->data['pagination']           = new stdClass();
        $this->data['pagination']->page     = $page;
        $this->data['pagination']->per_page = $perPage;

        // --------------------------------------------------------------------------

        //  Send any additional data
        $data                    = array();
        $data['include_body']    = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id);
        $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id);
        $data['sort']            = array('bp.published', 'desc');

        //  Only published items which are not schduled for the future
        $data['where']   = array();
        $data['where'][] = array('column' => 'blog_id',      'value' => $this->oBlog->id);
        $data['where'][] = array('column' => 'is_published', 'value' => true);
        $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false);

        // --------------------------------------------------------------------------

        //  Load posts and count
        $this->data['posts'] = $this->blog_post_model->getAll($page, $perPage, $data);
        $this->data['pagination']->total = $this->blog_post_model->countAll($data);

        // --------------------------------------------------------------------------

        //  Widgets
        $this->fetchSidebarWidgets();

        // --------------------------------------------------------------------------

        $this->data['isIndex'] = true;

        // --------------------------------------------------------------------------

        //  Load views
        $oView = Factory::service('View');
        $oView->load('structure/header', $this->data);
        $this->loadView('browse', $this->data);
        $oView->load('structure/footer', $this->data);
    }
398303
function crawLink($,result,linkTag, callback) {
      var link = $(linkTag).attr('href');
      var parentUrl = result.url;

      if (link) {

          var rel =  $(linkTag).attr('rel');

          if (result.linkTypes.indexOf(rel) > 0) {
              var linkUri = URI.linkToURI(parentUrl, link);

              pm.crawlLink(parentUrl, linkUri, null, null, function(){
                addLinkToQueue(result, parentUrl, linkUri, null, null, callback);
              });
          }
          else {
            callback();
          }
      }
      else {
        callback();
      }
}
1115984
def find_by_permalink!(permalink)
      result = scoped_by_permalink(permalink).first
      raise ActiveRecord::RecordNotFound.new "Could not find Content for Permalink id=#{permalink.id}" if result.nil?
      result
    end
1258289
public function filterPostTypeLink($permalink, $item, $leavename)
    {
        if (get_post_type($item->ID) == $this->singular)
        {
            $terms = wp_get_post_terms($item->ID, $this->taxonomy);
            $term = ($terms) ? $terms[0]->term_id : false;
            $permalink = $this->postTypePermalink($item->ID, $term, $leavename, false);
        }

        return $permalink;
    }
181930
function Link(name, data, prev, next) {

    /**
     * @public
     * @memberOf {Link}
     * @property
     * @type {String}
     * */
    this.name = name;

    /**
     * @public
     * @memberOf {Link}
     * @property
     * @type {Link}
     * */
    this.prev = prev;

    /**
     * @public
     * @memberOf {Link}
     * @property
     * @type {Link}
     * */
    this.next = next;

    /**
     * @public
     * @memberOf {Link}
     * @property
     * @type {*}
     * */
    this.data = data;
}
209010
static function snippet($text, $keywords, $limit, $max_length, $around = array('<b>', '</b>'))
	{
		$result = array();

		$keywords = self::normalize($keywords);
		list($pre, $post) = $around;
		$prev = array();
		$after = false;

		foreach(self::normalize_hash($text) as $word_orig => $word_norm)
		{
			$is_kw = false;
			if(in_array($word_norm, $keywords))
			{
				$prev[] = $pre.$word_orig.$post;
				$is_kw = true;
			}
			else
				$prev[] = $word_orig;

			if($is_kw)
			{
				if($after)
				{
					$result = array_merge($result, $prev);
					$prev = array();
				}
				else
				{
					$result = array_merge($result, count($prev) > $limit ? array('&#133') : array(), array_slice($prev, -$limit-1));
					$prev = array();
				}

				$after = true;
			}
			else
			{
				if($after && count($prev) >= $limit)
				{
					$after = false;
					$result = array_merge($result, $prev);
					$prev = array();
				}
			}
		}

		if($after)
			$result = array_merge($result, array('&#133'), $prev);

		return strip_text(join(' ', $result).'&#133;', $max_length);
	}
322925
public function permAssign($permid, $permvalue, $permskip = FALSE)
  {
    $this->getParent()->clientPermAssign($this["client_database_id"], $permid, $permvalue, $permskip);
  }