public static function autoLinkText($text, $options = array())
 {
     static $Html;
     if (!$Html) {
         if (!class_exists('HtmlHelper', false)) {
             \App::import('Helper', 'Html');
         }
         $Html = new \HtmlHelper();
         $Html->tags = $Html->loadConfig();
     }
     // Email
     $atom = '[a-z0-9!#$%&\'*+\\/=?^_`{|}~-]';
     $text = preg_replace_callback('/(' . $atom . '+(?:\\.' . $atom . '+)*@[a-z0-9-]+(?:\\.[a-z0-9-]+)*)/i', function ($matches) use($Html, $options) {
         return $Html->link($matches[0], "mailto:" . $matches[0], $options);
     }, $text);
     // http / web
     $text = preg_replace_callback('#(?<!href="|">)((?:https?|ftp|nntp)://[^\\s<>()]+)#i', function ($matches) use($Html, $options) {
         return $Html->link($matches[0], $matches[0], $options);
     }, $text);
     // http / web - part 2
     $text = preg_replace_callback('#(?<!href="|">)(?<!http://|https://|ftp://|nntp://)(www\\.[^\\n\\%\\ <]+[^<\\n\\%\\,\\.\\ <])(?<!\\))#i', function ($matches) use($Html, $options) {
         return $Html->link($matches[0], "http://" . $matches[0], $options);
     }, $text);
     return $text;
 }
示例#2
0
 /**
  * Returns link to remote action
  *
  * Returns a link to a remote action defined by <i>options[url]</i>
  * (using the url() format) that's called in the background using
  * XMLHttpRequest. The result of that request can then be inserted into a
  * DOM object whose id can be specified with <i>options[update]</i>.
  *
  * Examples:
  * <code>
  *  link("Delete this post",
  * array("update" => "posts", "url" => "delete/{$postid->id}"));
  *  link(imageTag("refresh"),
  *		array("update" => "emails", "url" => "list_emails" ));
  * </code>
  *
  * By default, these remote requests are processed asynchronous during
  * which various callbacks can be triggered (for progress indicators and
  * the likes).
  *
  * Example:
  * <code>
  *	link (word,
  *		array("url" => "undo", "n" => word_counter),
  *		array("complete" => "undoRequestCompleted(request)"));
  * </code>
  *
  * The callbacks that may be specified are:
  *
  * - <i>loading</i>::		Called when the remote document is being
  *							loaded with data by the browser.
  * - <i>loaded</i>::		Called when the browser has finished loading
  *							the remote document.
  * - <i>interactive</i>::	Called when the user can interact with the
  *							remote document, even though it has not
  *							finished loading.
  * - <i>complete</i>:: Called when the XMLHttpRequest is complete.
  *
  * If you for some reason or another need synchronous processing (that'll
  * block the browser while the request is happening), you can specify
  * <i>options[type] = synchronous</i>.
  *
  * You can customize further browser side call logic by passing
  * in Javascript code snippets via some optional parameters. In
  * their order of use these are:
  *
  * - <i>confirm</i>:: Adds confirmation dialog.
  * -<i>condition</i>::	Perform remote request conditionally
  *                      by this expression. Use this to
  *                      describe browser-side conditions when
  *                      request should not be initiated.
  * - <i>before</i>::		Called before request is initiated.
  * - <i>after</i>::		Called immediately after request was
  *						initiated and before <i>loading</i>.
  *
  * @param string $title Title of link
  * @param mixed $url Cake-relative URL or array of URL parameters, or external URL (starts with http://)
  * @param array $options Options for JavaScript function
  * @param string $confirm Confirmation message. Calls up a JavaScript confirm() message.
  *
  * @return string HTML code for link to remote action
  * @link http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/AJAX.html#link
  */
 function link($title, $url = null, $options = array(), $confirm = null)
 {
     if (!isset($url)) {
         $url = $title;
     }
     if (!isset($options['url'])) {
         $options['url'] = $url;
     }
     if (!empty($confirm)) {
         $options['confirm'] = $confirm;
         unset($confirm);
     }
     $htmlOptions = $this->__getHtmlOptions($options, array('url'));
     $options += array('safe' => true);
     unset($options['escape']);
     if (empty($options['fallback']) || !isset($options['fallback'])) {
         $options['fallback'] = $url;
     }
     $htmlDefaults = array('id' => 'link' . intval(mt_rand()), 'onclick' => '');
     $htmlOptions = array_merge($htmlDefaults, $htmlOptions);
     $htmlOptions['onclick'] .= ' event.returnValue = false; return false;';
     $return = $this->Html->link($title, $url, $htmlOptions);
     $callback = $this->remoteFunction($options);
     $script = $this->Javascript->event("'{$htmlOptions['id']}'", "click", $callback);
     if (is_string($script)) {
         $return .= $script;
     }
     return $return;
 }
示例#3
0
 function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
 {
     $matches = Set::extract("/Upload[type_id={$this->config[0]}]", $params['Upload']);
     $unapproved = Set::extract('/Upload[approved=0]', $matches);
     if (empty($unapproved)) {
         if ($text_reason) {
             $this->reason = sprintf(__('have uploaded the %s', true), $this->document);
         } else {
             App::import('Helper', 'Html');
             $html = new HtmlHelper();
             $url = array('controller' => 'people', 'action' => 'document_upload', 'type' => $this->config[0]);
             if ($absolute_url) {
                 $url = $html->url($url, true);
             } else {
                 $url['return'] = true;
             }
             $this->reason = $html->link(sprintf(__('have uploaded the %s', true), $this->document), $url);
         }
     } else {
         $this->reason = sprintf(__('wait until your %s is approved', true), $this->document);
     }
     if (!$strict) {
         return true;
     }
     if (is_array($params) && array_key_exists('Upload', $params)) {
         $date = date('Y-m-d', strtotime($this->config[1]));
         $matches = Set::extract("/Upload[type_id={$this->config[0]}][valid_from<={$date}][valid_until>={$date}]", $params['Upload']);
         if (!empty($matches)) {
             return true;
         }
     }
     return false;
 }
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if ($this->isAllowed($url)) {
         return parent::link($title, $url, $options, $confirmMessage);
     }
     return '';
 }
示例#5
0
 function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
 {
     $events = array();
     if ($text_reason) {
         foreach ($this->events as $event) {
             $events[] = $event['Event']['name'];
         }
     } else {
         App::import('Helper', 'Html');
         $html = new HtmlHelper();
         foreach ($this->events as $event) {
             $url = array('controller' => 'events', 'action' => 'view', 'event' => $event['Event']['id']);
             if ($absolute_url) {
                 $url = $html->url($url, true);
             } else {
                 $url['return'] = true;
             }
             $events[] = $html->link($event['Event']['name'], $url);
         }
     }
     $this->reason = __('have previously registered for the', true) . ' ' . implode(' ' . __('or', true) . ' ', $events);
     if (is_array($params) && array_key_exists('Registration', $params)) {
         $registered = Set::extract('/Registration/Event/id', $params);
         $prereqs = array_intersect($registered, $this->config);
         if (!empty($prereqs)) {
             return true;
         }
     }
     return false;
 }
示例#6
0
文件: functions.php 项目: jxav/frage
 function abm($id, $controller, $enclosed = null)
 {
     /* Load HTML helper */
     App::import('Helper', 'Html');
     $html = new HtmlHelper();
     $abm = ' ';
     if ($enclosed) {
         $abm .= "<{$enclosed}>";
     }
     $abm .= $html->link(__('[Edit]', true), array('controller' => $controller, 'action' => 'edit', $id)) . ' ';
     $abm .= $html->link(__('[×]', true), array('controller' => $controller, 'action' => 'delete', $id), null, sprintf(__('Are you sure you want to delete # %s?', true), $id));
     if ($enclosed) {
         $abm .= "</{$enclosed}>";
     }
     return $abm;
 }
示例#7
0
 function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
 {
     $linkUrl = parent::url($url);
     $currentUrl = $this->here;
     // Remove paging from currentUrl
     // @TODO if another named param goes after paging it do it's thing
     $pieces = explode('/', $currentUrl);
     $paging = end($pieces);
     if (strpos($paging, 'page:') === 0) {
         array_pop($pieces);
         $currentUrl = join('/', $pieces);
     }
     if (isset($htmlAttributes['strict']) and $htmlAttributes['strict']) {
         $htmlAttributes['currentOn'] = $url;
     }
     $currentOverride = false;
     if (isset($htmlAttributes['currentOn']) && !is_null($htmlAttributes['currentOn'])) {
         if ($currentUrl === parent::url($htmlAttributes['currentOn'])) {
             $currentOverride = true;
         }
     }
     if (strpos($currentUrl, $linkUrl) === 0 && (!isset($htmlAttributes['currentOn']) || is_null($htmlAttributes['currentOn'])) || $currentOverride === true) {
         if (!isset($htmlAttributes['class'])) {
             $htmlAttributes['class'] = '';
         }
         $classes = explode(' ', $htmlAttributes['class']);
         if (!isset($classes['current'])) {
             $classes[] = 'current';
         }
         $htmlAttributes['class'] = join(' ', $classes);
     }
     unset($htmlAttributes['currentOn']);
     return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
 }
示例#8
0
 function evaluate($affiliate, $params, $team, $strict, $text_reason, $complete, $absolute_url)
 {
     if ($text_reason) {
         $this->reason = sprintf(__('have signed the %s waiver', true), $this->waiver);
     } else {
         App::import('Helper', 'Html');
         $html = new HtmlHelper();
         $url = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
         if ($absolute_url) {
             $url = $html->url($url, true);
         } else {
             $url['return'] = true;
         }
         $this->reason = $html->link(sprintf(__('have signed the %s waiver', true), $this->waiver), $url);
     }
     $this->redirect = array('controller' => 'waivers', 'action' => 'sign', 'waiver' => $this->config[0], 'date' => $this->date);
     if (!$strict) {
         $this->invariant = true;
         return true;
     }
     if (is_array($params) && array_key_exists('Waiver', $params)) {
         $matches = array_intersect($this->config, Set::extract("/Waiver/WaiversPerson[valid_from<={$this->date}][valid_until>={$this->date}]/waiver_id", $params));
         if (!empty($matches)) {
             $this->invariant = true;
             return true;
         }
     }
     return false;
 }
示例#9
0
 function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
 {
     // $parsedUrl = rtrim(parent::url($url), '/');
     //         $parsedUrl = rtrim($parsedUrl, '/index');
     //         $currentUrl = rtrim($this->here, '/');
     //         $currentUrl = rtrim($currentUrl, '/index');
     //         $linksToCurrentPage = (bool)($parsedUrl === $currentUrl);
     //
     //         $containsCurrentPage = (bool)(strpos($currentUrl, $parsedUrl) === 0);
     //
     //         if ($linksToCurrentPage or (!isset($htmlAttributes['strict']) and $containsCurrentPage)) {
     //             if (isset($htmlAttributes['class'])) {
     //                 $htmlAttributes['class'] = $htmlAttributes['class'] + ' current';
     //             } else {
     //                 $htmlAttributes['class'] = 'current';
     //             }
     //         }
     //
     //         unset($htmlAttributes['strict']);
     $parsedUrl = rtrim(parent::url($url), '/');
     $parsedUrl = rtrim($parsedUrl, '/index');
     $currentUrl = rtrim($this->here, '/');
     $currentUrl = rtrim($currentUrl, '/index');
     $linksToCurrentPage = (bool) ($parsedUrl === $currentUrl);
     $isPartOfUrl = (bool) (strpos($currentUrl, $parsedUrl) === 0);
     if ($linksToCurrentPage or !isset($htmlAttributes['strict']) and $isPartOfUrl) {
         if (isset($htmlAttributes['class'])) {
             $htmlAttributes['class'] += ' current';
         } else {
             $htmlAttributes['class'] = 'current';
         }
     }
     return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
 }
示例#10
0
/**
 * Returns link to remote action
 *
 * Returns a link to a remote action defined by <i>options[url]</i>
 * (using the url() format) that's called in the background using
 * XMLHttpRequest. The result of that request can then be inserted into a
 * DOM object whose id can be specified with <i>options[update]</i>.
 *
 * Examples:
 * <code>
 *  link("Delete this post",
 * array("update" => "posts", "url" => "delete/{$postid->id}"));
 *  link(imageTag("refresh"),
 *		array("update" => "emails", "url" => "list_emails" ));
 * </code>
 *
 * By default, these remote requests are processed asynchronous during
 * which various callbacks can be triggered (for progress indicators and
 * the likes).
 *
 * Example:
 * <code>
 *	link (word,
 *		array("url" => "undo", "n" => word_counter),
 *		array("complete" => "undoRequestCompleted(request)"));
 * </code>
 *
 * The callbacks that may be specified are:
 *
 * - <i>loading</i>::		Called when the remote document is being
 *							loaded with data by the browser.
 * - <i>loaded</i>::		Called when the browser has finished loading
 *							the remote document.
 * - <i>interactive</i>::	Called when the user can interact with the
 *							remote document, even though it has not
 *							finished loading.
 * - <i>complete</i>:: Called when the XMLHttpRequest is complete.
 *
 * If you for some reason or another need synchronous processing (that'll
 * block the browser while the request is happening), you can specify
 * <i>options[type] = synchronous</i>.
 *
 * You can customize further browser side call logic by passing
 * in Javascript code snippets via some optional parameters. In
 * their order of use these are:
 *
 * - <i>confirm</i>:: Adds confirmation dialog.
 * -<i>condition</i>::	Perform remote request conditionally
 *                      by this expression. Use this to
 *                      describe browser-side conditions when
 *                      request should not be initiated.
 * - <i>before</i>::		Called before request is initiated.
 * - <i>after</i>::		Called immediately after request was
 *						initiated and before <i>loading</i>.
 *
 * @param string $title Title of link
 * @param string $href Href string "/products/view/12"
 * @param array $options		Options for JavaScript function
 * @param string $confirm		Confirmation message. Calls up a JavaScript confirm() message.
 * @param boolean $escapeTitle  Escaping the title string to HTML entities
 *
 * @return string				HTML code for link to remote action
 */
	function link($title, $href = null, $options = array(), $confirm = null, $escapeTitle = true) {
		if (!isset($href)) {
			$href = $title;
		}
		if (!isset($options['url'])) {
			$options['url'] = $href;
		}

		if (isset($confirm)) {
			$options['confirm'] = $confirm;
			unset($confirm);
		}
		$htmlOptions = $this->__getHtmlOptions($options, array('url'));

		$htmlDefaults = array('id' => 'link' . intval(mt_rand()), 'onclick' => '');
		$htmlOptions = array_merge($htmlDefaults, $htmlOptions);

		$htmlOptions['onclick'] .= ' return false;';
		$return = $this->Html->link($title, $href, $htmlOptions, null, $escapeTitle);
		$callback = $this->remoteFunction($options);
		$script = $this->Javascript->event("'#{$htmlOptions['id']}'", "click", $callback);

		if (is_string($script)) {
			$return .= $script;
		}
		return $return;
	}
示例#11
0
 /**
  * create tweet button
  *
  * @see http://dev.twitter.com/pages/tweet_button
  * @param string  $label
  * @param array   $options
  * @param boolean $dataAttribute
  * @param boolean $scriptInline
  * @return string
  */
 public function tweetButton($label = null, $options = array(), $dataAttribute = false, $scriptInline = false)
 {
     $attributes = array();
     $defaults = array('class' => 'twitter-share-button', 'url' => '', 'via' => '', 'text' => '', 'related' => '', 'count' => 'horizontal', 'lang' => 'en', 'counturl' => '');
     if (empty($label)) {
         $label = 'Tweet';
     }
     $options = am($defaults, $options);
     $attributes['class'] = $options['class'];
     unset($options['class']);
     $options['count'] = strtolower($options['count']);
     if (!in_array($options['count'], array('none', 'horizontal', 'vertical'))) {
         $options['count'] = 'none';
     }
     $options = Set::filter($options);
     if ($dataAttribute) {
         foreach ($options as $key => $val) {
             $attributes['data-' . $key] = $val;
         }
         $options = array();
     }
     $out = $this->Html->link($label, 'http://twitter.com/share' . Router::queryString($options), $attributes);
     $out .= $this->Html->script('http://platform.twitter.com/widgets.js', array('inline' => $scriptInline));
     return $this->output($out);
 }
示例#12
0
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if (!is_array($url)) {
         $tmp = Router::parse($url);
     } else {
         $tmp = $url;
     }
     if (!isset($this->request->params['action'])) {
         $this->request->params['action'] = 'index';
     }
     if (!isset($tmp['action'])) {
         $tmp['action'] = 'index';
     }
     if ($tmp['controller'] == $this->request->params['controller']) {
         if (!isset($options) || !is_array($options)) {
             $options = array();
         }
         if (!isset($options['class'])) {
             $options['class'] = 'current-controller';
         } else {
             $options['class'] .= ' current-controller';
         }
         if ($tmp['action'] == $this->request->params['action'] || $this->request->params['controller'] == 'Pages' && $this->request->params['action'] == 'display' && $this->request->params['pass'][0] == $tmp['action']) {
             $options['class'] .= ' current-page';
             if (isset($tmp[0]) && isset($this->request->params['pass']) && isset($this->request->params['pass'][0]) && $tmp[0] == $this->request->params['pass'][0]) {
                 $options['class'] .= ' current-item';
             }
         }
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#13
0
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if (!isset($url['language']) && isset($this->params['language'])) {
         $url['language'] = $this->params['language'];
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#14
0
 /**
  * Генерация ссылки с проверкой доступа по ролевой модели
  * @param string $title
  * @param null $url
  * @param array $options
  * @param bool $confirmMessage
  * @return null|string
  */
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if ($this->_aclCheck($url)) {
         return parent::link($title, $url, $options, $confirmMessage);
     } else {
         return null;
     }
 }
示例#15
0
 function link($title, $url = NULL, $options = array(), $confirmMessage = false)
 {
     if (!is_array($url)) {
         return parent::link($title, $url . $this->getLinkTitle($title), $options, $confirmMessage);
     } else {
         return parent::link($title, $url, $options, $confirmMessage);
     }
 }
示例#16
0
文件: breadcrumbs.php 项目: soska/dte
 function _singleBreadcrumbs($options)
 {
     $cats = get_the_category();
     $id = $cats[0]->cat_ID;
     $links = $this->_getCategoryParentLinks($id, $options);
     $links[] = HtmlHelper::link(get_the_title(), get_permalink());
     return $this->_list($links);
 }
示例#17
0
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if ($confirmMessage) {
         $options['data-confirm'] = $confirmMessage;
         $confirmMessage = false;
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#18
0
    function index()
    {
        App::import('Helper', 'Html');
        // loadHelper('Html'); in CakePHP 1.1.x.x
        $html = new HtmlHelper();
        $source_link = $html->link('check out', 'http://code.google.com/p/cakewell/source/checkout', array('target' => '_blank'));
        $browse_link = $html->link('browse', 'http://code.google.com/p/cakewell/source/browse/app/controllers/backend_controller.php', array('target' => '_blank'));
        $menu = $html->link('demo controller', '/demo');
        $content = <<<XHTML
<p>The backend controller offers basic administrative control over logs and
cache files.</p>
<p>It is not currently set up to run in production for security reasons.  To
use it, %s or %s the source code.</p>
XHTML;
        $this->set('header', 'Cakewell Backend');
        $this->set('content', sprintf($content, $source_link, $browse_link));
        $this->set('menu', $menu);
        $this->render('/demo/index');
    }
示例#19
0
 /**
  * Extend the default link function by allowing for shortening link titles.
  */
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if (is_array($options) && array_key_exists('max_length', $options)) {
         $max = $options['max_length'];
         unset($options['max_length']);
         if (strlen($title) > $max) {
             $options['title'] = $title;
             $title = $this->Text->truncate($title, $max);
         }
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#20
0
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $defaults = array('current' => false);
     $options = am($defaults, $options);
     if ($options['current']) {
         if ($options['current'] === true) {
             $set = false;
             if (!is_array($url)) {
                 if ($this->params['controller'] === 'feeds' && $url === '/home' && !$this->Session->check('Workspace')) {
                     $set = true;
                 }
             } elseif (!empty($url['controller'])) {
                 if ($url['controller'] === $this->params['controller']) {
                     $set = true;
                 }
                 if ($this->Session->check('Stack') || $this->Session->check('Milestone') || $this->Session->check('Workspace')) {
                     if ($this->Session->check('Stack')) {
                         if ($url['controller'] === 'stacks' && $url[0] === $this->Session->read('Stack.id')) {
                             $set = true;
                         }
                     } elseif ($this->Session->check('Milestone')) {
                         if ($url['controller'] === 'milestones' && $url[0] === $this->Session->read('Milestone.id')) {
                             $set = true;
                         }
                     } elseif ($this->Session->check('Workspace')) {
                         if ($url['controller'] === 'workspaces' && $url[0] === $this->Session->read('Workspace.id')) {
                             $set = true;
                         }
                     }
                 }
                 $repoControllers = array('source', 'commits', 'timeline', 'projects', 'dashboard', 'project_permissions', 'repo', 'users');
                 if (in_array($this->params['controller'], $repoControllers) && $url['controller'] === 'projects') {
                     $set = true;
                 }
             }
             if ($set) {
                 if (!empty($options['class'])) {
                     $options['class'] .= ' current';
                 } else {
                     $options['class'] = 'current';
                 }
             }
         }
     }
     // unset our custom options
     unset($options['current']);
     // kick them out of plugins, usernames, projects, and admin
     if (is_array($url)) {
         $url = am(array('plugin' => false, 'username' => false, 'project' => false, 'admin' => false), $url);
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#21
0
 function open_toggle_box($title = null)
 {
     App::import('Helper', 'Html');
     $html = new HtmlHelper();
     if (!$title) {
         $title = 'NONE';
     } else {
         $title = $html->link($title, '#', array("id" => 'toggle-' . strtolower($title)));
     }
     //print pr($title);die();
     $text = '<div class="box">' . '<h2>' . $title . '</h2>' . '<div class="block" id="' . strtolower($title) . '">';
     return $text;
 }
 function parseMessage($inventory, $message)
 {
     App::uses('HtmlHelper', 'View/Helper');
     $htmlHelper = new HtmlHelper($this->_View);
     $messageArray = explode(" ", $message);
     for ($i = 0; $i < count($messageArray); $i++) {
         $aString = trim($messageArray[$i]);
         if (array_key_exists($aString, $inventory)) {
             $messageArray[$i] = $htmlHelper->link($aString, '/inventory/moreInfo/' . $inventory[$aString]);
         }
     }
     return implode(" ", $messageArray);
 }
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $default = array('icon' => null, 'escape' => true);
     $options += $default;
     if ($options['icon']) {
         if ($options['escape']) {
             $title = h($title);
         }
         $title = $this->icon($options['icon']) . ' ' . $title;
         $options['escape'] = false;
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#24
0
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $permissions = $this->Session->read('Alaxos.Acl.permissions');
     if (!isset($permissions)) {
         $permissions = array();
     }
     $aco_path = AclRouter::aco_path($url);
     if (isset($permissions[$aco_path]) && $permissions[$aco_path] == 1) {
         return parent::link($title, $url, $options, $confirmMessage);
     } else {
         return null;
     }
 }
示例#25
0
 public function index()
 {
     $shortUrl = '';
     if (!empty($this->data)) {
         if ($shortUrl = $this->Shorturl->shortUrl($this->data)) {
             App::import('Helper', 'Html');
             $html = new HtmlHelper();
             $this->Session->setFlash(sprintf(__('Your new Url is %s', true), $html->link($shortUrl['Shorturl']['short'], $shortUrl['Shorturl']['short'])), 'success');
             $this->redirect(array('action' => 'index'));
         } else {
             $this->Session->setFlash(sprintf(__('The %s could not be shortened. Please, try again.', true), __('Url', true)), 'error');
         }
     }
 }
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $default = array('icon' => null, 'escape' => true, 'glyph' => false);
     $options = array_merge($default, (array) $options);
     if ($options['icon']) {
         if ($options['escape']) {
             $title = h($title);
         }
         $title = $this->icon($options['icon'], $options['glyph']) . ' ' . $title;
         $options['escape'] = false;
         unset($options['icon'], $options['glyph']);
     }
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#27
0
 /**
  * Html::link redefinition
  * Don't generate link if disabled in options
  * Allow wrapping the link in another html tag
  * @param $name
  * @param $url
  * @param $options
  */
 function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $defaultOptions = array('class' => '', 'wrap' => false);
     $options = array_merge($defaultOptions, $options);
     if (isset($options['disabled']) && $options['disabled']) {
         if ($this->DisplaySettings->showDisabledLinks()) {
             $link = '<span class="link disabled ' . $options['class'] . '">' . $title . '</span>';
         } else {
             return;
         }
     } else {
         $link = parent::link($title, $url, $options, $confirmMessage);
     }
     if ($options['wrap']) {
         $link = $this->tag($options['wrap'], $link);
     }
     return $link;
 }
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     $default = array('icon' => null, 'escape' => true, 'fonticon' => true);
     $options = array_merge($default, (array) $options);
     // just for BC
     if (isset($options['glyph']) && $options['glyph'] === false || !$options['fonticon']) {
         $options['fonticon'] = false;
         unset($options['glyph']);
     }
     if ($options['icon']) {
         if ($options['escape']) {
             $title = h($title);
         }
         $title = $this->icon($options['icon'], $options['fonticon']) . ' ' . $title;
         $options['escapeTitle'] = false;
     }
     unset($options['icon'], $options['fonticon']);
     return parent::link($title, $url, $options, $confirmMessage);
 }
示例#29
0
 public function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
 {
     if ($url !== null) {
         $url = $this->url($url);
     } else {
         $url = $this->url($title);
         $title = $url;
         $escapeTitle = false;
     }
     if (isset($this->base) && $this->base != '/') {
         $url = str_replace($this->base, '', $url);
     }
     $formPatterns = array('add', 'edit', 'delete');
     if (preg_match('/\\/' . join('|', $formPatterns) . '\\//', $url)) {
         if (strpos($this->params['url']['url'], 'backTo:') !== false) {
             $this->params['url']['url'] = preg_replace('/backTo\\:.*$/', '', $this->params['url']['url']);
         }
         $url = $url . '/' . 'backTo:' . rawurlencode(strtr($this->params['url']['url'], '/', '~'));
     }
     return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
 }
示例#30
0
 function link($title, $url = null, $htmlAttributes = array(), $confirmMessage = false, $escapeTitle = true)
 {
     $linkUrl = parent::url($url);
     $currentUrl = $this->here;
     $currentOverride = false;
     if (isset($htmlAttributes['currentOn']) && !is_null($htmlAttributes['currentOn'])) {
         if ($currentUrl === parent::url($htmlAttributes['currentOn'])) {
             $currentOverride = true;
         }
     }
     if (strpos($currentUrl, $linkUrl) === 0 && (!isset($htmlAttributes['currentOn']) || is_null($htmlAttributes['currentOn'])) || $currentOverride === true) {
         if (!isset($htmlAttributes['class'])) {
             $htmlAttributes['class'] = '';
         }
         $classes = explode(' ', $htmlAttributes['class']);
         if (!isset($classes['current'])) {
             $classes[] = 'current';
         }
         $htmlAttributes['class'] = join(' ', $classes);
     }
     unset($htmlAttributes['currentOn']);
     return parent::link($title, $url, $htmlAttributes, $confirmMessage, $escapeTitle);
 }