Inheritance: extends Helper
Ejemplo n.º 1
0
 public function beforeSave($options = array())
 {
     Configure::write('debug', 2);
     App::uses("HtmlHelper", "View/Helper");
     $html = new HtmlHelper(new View());
     if ($this->data[$this->alias]['image']['name'] != "") {
         $ext = pathinfo($this->data[$this->alias]['image']['name'], PATHINFO_EXTENSION);
         $image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
         $destination = "files/recipe_images/" . $image_name;
         if (move_uploaded_file($this->data[$this->alias]['image']['tmp_name'], $destination)) {
             $bowl = $this->createBowl($destination);
             $tmp = explode("/", $bowl);
             $destination2 = "files/recipe_images/" . $tmp[1];
             //unlink($destination);
             rename($destination, $dt = "files/recipe_images/ori/" . $tmp[1]);
             rename($bowl, $destination2);
         }
         $this->data[$this->alias]['image'] = $html->url("/" . $dt, true);
         $this->data[$this->alias]['image_bowl'] = $html->url("/" . $destination2, true);
     } else {
         unset($this->data[$this->alias]['image']);
     }
     parent::beforeSave($options);
     return true;
 }
Ejemplo n.º 2
0
 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;
 }
Ejemplo n.º 3
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;
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
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;
 }
 /**
  * _addScripts method
  *
  * Adds properties
  *
  * @param mixed $view
  * @return boolean
  */
 public function _addScripts($view)
 {
     if ($this->request->params['plugin'] == 'lil_invoices') {
         App::uses('HtmlHelper', 'View/Helper');
         $Html = new HtmlHelper($view);
         $Html->css('/lil_invoices/css/lil_invoices.css', null, array('inline' => false));
     }
     return true;
 }
 /**
  * _addScripts method
  *
  * Adds properties
  *
  * @param mixed $view
  * @return boolean
  */
 public function _addScripts($view)
 {
     if ($this->request->params['plugin'] == 'lil_tasks' || $this->request->params['plugin'] == 'lil' && $this->request->params['action'] == 'admin_dashboard') {
         App::uses('HtmlHelper', 'View/Helper');
         $Html = new HtmlHelper($view);
         $Html->css('/lil_tasks/css/lil_tasks.css', null, array('inline' => false));
         $Html->script('/lil_tasks/js/lil_tasks.js');
     }
     return true;
 }
Ejemplo n.º 8
0
 /**
  * Return language flag image url
  *
  * @param int $id
  * @param mixed $attrs Html attributes of the flag image
  */
 function flag($id = null, $attrs = array())
 {
     if (empty($id)) {
         $id = $this->langID();
     }
     //if
     $objLang = new Language();
     $lang = $objLang->read('flag', $id);
     return $this->Html->image('/img/flags/' . $lang['Language']['flag'], $attrs);
 }
 /**
  * Sends HttpSocket requests. Builds your uri and formats the response too.
  *
  * @param Model $model Model object
  * @param mixed $requestData Array of request or string uri
  * @param string $requestMethod read, create, update, delete
  *
  * @return array|false $response
  */
 public function request(Model $model = null, $requestData = null, $requestMethod = HttpSource::METHOD_READ)
 {
     if ($model === null) {
         return parent::request($model, $requestData, $requestMethod);
     }
     $HtmlHelper = new HtmlHelper(new View());
     unset($model->request['uri'], $model->request['virtual']);
     $model->request['body'] = '<?xml version="1.0" encoding="utf-8"?>' . $HtmlHelper->tag('request', $model->request['body']);
     return parent::request($model, $requestData, $requestMethod);
 }
Ejemplo n.º 10
0
 function __toString()
 {
     $help = new HtmlHelper();
     $html = $help->css('/admin/custom/formtabs.css') . $help->javascript('/admin/custom/formtabs.js');
     $html .= '<div id="tabs">';
     foreach ($this->tabs as $tab) {
         $html .= $help->absoluteLink($tab[0], '#' . $tab[1]);
     }
     $html .= '<div class="clear"></div></div>';
     $html .= $this->getClientValidationHtml();
     return $html;
 }
Ejemplo n.º 11
0
 function add()
 {
     //$this->view = "View";  //qdmailとdebug kitを併用するとエラー起きるのでその対策、本番環境では当然いらない
     //Configure::write('debug',0);
     $this->layout = 'ajax';
     // ログインしていない、または自分のuser_idをフォローしようとしていたらjsonに何もセットせず、結果的にjasonでnullのみを返す
     if (($id = $this->Auth->user('id')) === null || $this->Auth->user('id') === $this->params['follow_id']) {
         //$this->cakeError('error404');
         //$this->redirect($this->Auth->logout());
     } else {
         $res['login'] = TRUE;
         //ちゃんとloginしている場合はjsonファイルに設定、というかここがtrueだと処理成功とjsonで判断される
     }
     //var_dump($this->Auth->user('id'));
     $data['Follow'] = array('user_id' => $id, 'follow_user_id' => $this->params['follow_id']);
     //var_dump($data);
     //$this->data = $data;
     $this->Follow->create();
     if ($this->Follow->save($data)) {
         //$this->Session->setFlash(__('The Follow has been saved', true));
         //メールの送信準備
         $this->User->unbindModel(array('hasMany' => array('Task')), false);
         //twitter投稿用のuser情報だけ欲しいのでunbind
         $user = $this->User->findAllById($this->params['follow_id']);
         //pr($user);
         if ($user[0]['User']['email'] && $user[0]['User']['follow_mail_enabled']) {
             //followした人の名前情報
             $following_name = $this->Auth->user('realname') ? $this->Auth->user('realname') : $this->Auth->user('username');
             //followした人の詳しい名前情報
             $following_2name = $this->Auth->user('realname') ? "{$this->Auth->user('realname')} ({$this->Auth->user('username')})" : $this->Auth->user('username');
             //followされた人の名前情報
             //$follower_name = $user[0]['User']['realname'] ? $user[0]['User']['realname'] : $user[0]['User']['username'] ;
             //followされた人の詳しい名前情報
             $follower_2name = $user[0]['User']['realname'] ? "{$user[0]['User']['realname']} ({$user[0]['User']['username']})" : $user[0]['User']['username'];
             //ドメインを含んだ絶対URLの取得
             App::import('Helper', 'Html');
             $html = new HtmlHelper();
             $base_url = $html->url(array('controller' => $this->Auth->user('username')), true);
             //$res = array($user,$follow_username,$follow_realname,$following_username,$user[0]['User']['email'],);
             //メールの送信
             $this->QdmailWrap->address = $user[0]['User']['email'];
             $this->QdmailWrap->subject = "{$following_name}があなたをフォローし始めました";
             $this->QdmailWrap->message = "こんにちは、{$follower_2name}さん。\n\n{$following_2name} があなたをフォローし始めました。\n\n{$following_name}さんのプロフィールはこちらまで:\n  {$base_url}\n\n{$following_name}をフォローするために、「フォロー」のボタンをクリックしてください\nりすったー。\n \n--\nリスッターから「follow notification」のメールを受信したくない場合は、今すぐ解除できます。リスッターからのメール選択について再度登録や変更をしたい場合は、自分のアカウントから「設定」へ行きお知らせ機能を操作してください。";
             if ($this->QdmailWrap->post()) {
                 //メール送信に成功したら
             }
         }
     }
     //$res['test']='testdayo';
     $this->set('result', json_encode($res));
     $this->render(null, null, VIEWS . DS . 'ajax.ctp');
     // Ajax 用共通 view
 }
Ejemplo n.º 12
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;
 }
Ejemplo n.º 13
0
 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);
 }
Ejemplo n.º 14
0
 public function beforeSave($options = array())
 {
     App::uses("HtmlHelper", "View/Helper");
     $html = new HtmlHelper(new View());
     if ($this->data[$this->alias]['name'] != "") {
         $ext = pathinfo($this->data[$this->alias]['name'], PATHINFO_EXTENSION);
         $image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
         $this->data[$this->alias]['path'] = $html->url("/files/sentdesigns/" . $image_name, true);
         $destination = "files/sentdesigns/" . $image_name;
         move_uploaded_file($this->data[$this->alias]['tmp_name'], $destination);
     }
     parent::beforeSave($options);
 }
Ejemplo n.º 15
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');
         }
     }
 }
Ejemplo n.º 16
0
 function __toString()
 {
     $this->_html_name = $this->_name . '[file]';
     if ($this->current_filename == '') {
         return parent::__toString();
     }
     $html = new HtmlHelper();
     $id = $this->getAttribute('id');
     $button = '<div id="editablebox_' . $id . '">' . $this->current_filename . ' ';
     $button .= $html->absoluteLink('[X]', 'javascript:void(0)', array('id' => 'delete_' . $id));
     $button .= $html->inlineJavascript('Phaxsi.Event.addEvent(document.getElementById("delete_' . $id . '"), "click", deleteFile.createDelegate(this, ["' . $id . '", "' . $this->input_hidden->getAttribute('id') . '"]));');
     $button .= '</div>';
     $this->beforeHTML = $html->javascript('/widgets/custom/editablefile.js') . $button . $this->input_hidden->__toString();
     return parent::__toString();
 }
Ejemplo n.º 17
0
 public function beforeSave($options = array())
 {
     App::uses("HtmlHelper", "View/Helper");
     $html = new HtmlHelper(new View());
     if (!empty($this->data[$this->alias]['file']['name'])) {
         $this->data[$this->alias]['type'] = $this->data[$this->alias]['file']['type'];
         $this->data[$this->alias]['movefile'] = $this->data[$this->alias]['file'];
         $ext = pathinfo($this->data[$this->alias]['file']['name'], PATHINFO_EXTENSION);
         $image_name = date('YmdHis') . rand(1, 999) . "." . $ext;
         $this->data[$this->alias]['file'] = $html->url("/files/splash/" . $image_name, true);
         $this->data[$this->alias]['movefile']['name'] = $image_name;
     }
     parent::beforeSave($options);
     return true;
 }
Ejemplo n.º 18
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);
 }
Ejemplo n.º 19
0
 public function url($url = null, $full = false)
 {
     if (!isset($url['language']) && isset($this->params['language'])) {
         $url['language'] = $this->params['language'];
     }
     return parent::url($url, $full);
 }
Ejemplo n.º 20
0
 /**
  * Returns one or many `<script>` tags depending on the number of scripts given.
  *
  * If the filename is prefixed with "//", it will be returned early as its a special http(s) indepenent url.
  *
  * If the filename is prefixed with "/", the path will be relative to the base path of your
  * application.  Otherwise, the path will be relative to your JavaScript path, usually webroot/js.
  *
  * Can include one or many Javascript files.
  *
  * ### Options
  *
  * - `inline` - Whether script should be output inline or into scripts_for_layout.
  * - `once` - Whether or not the script should be checked for uniqueness. If true scripts will only be
  *   included once, use false to allow the same script to be included more than once per request.
  *
  * @param mixed $url String or array of javascript files to include
  * @param mixed $options Array of options, and html attributes see above. If boolean sets $options['inline'] = value
  * @return mixed String of `<script />` tags or null if $inline is false or if $once is true and the file has been
  *   included before.
  * @access public
  * @link http://book.cakephp.org/view/1589/script
  */
 function script($url, $options = array())
 {
     if (strpos((string) $url, '//') !== false) {
         return sprintf($this->tags['javascriptlink'], $url, null);
     }
     return parent::script($url, $options);
 }
Ejemplo n.º 21
0
 /**
  * Create a text field with Autocomplete.
  *
  * Creates an autocomplete field with the given ID and options.
  *
  * options['with'] defaults to "Form.Element.serialize('$field')",
  * but can be any valid javascript expression defining the additional fields.
  *
  * @param string $field DOM ID of field to observe
  * @param string $url URL for the autocomplete action
  * @param array $options Ajax options
  * @return string Ajax script
  * @link http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/AJAX.html#autoComplete
  */
 function autoComplete($field, $url = "", $options = array())
 {
     $var = '';
     if (isset($options['var'])) {
         $var = 'var ' . $options['var'] . ' = ';
         unset($options['var']);
     }
     if (!isset($options['id'])) {
         $options['id'] = Inflector::camelize(str_replace(".", "_", $field));
     }
     $divOptions = array('id' => $options['id'] . "_autoComplete", 'class' => isset($options['class']) ? $options['class'] : 'auto_complete');
     if (isset($options['div_id'])) {
         $divOptions['id'] = $options['div_id'];
         unset($options['div_id']);
     }
     $htmlOptions = $this->__getHtmlOptions($options);
     $htmlOptions['autocomplete'] = "off";
     foreach ($this->autoCompleteOptions as $opt) {
         unset($htmlOptions[$opt]);
     }
     if (isset($options['tokens'])) {
         if (is_array($options['tokens'])) {
             $options['tokens'] = $this->Javascript->object($options['tokens']);
         } else {
             $options['tokens'] = '"' . $options['tokens'] . '"';
         }
     }
     $options = $this->_optionsToString($options, array('paramName', 'indicator'));
     $options = $this->_buildOptions($options, $this->autoCompleteOptions);
     $text = $this->Form->text($field, $htmlOptions);
     $div = $this->Html->div(null, '', $divOptions);
     $script = "{$var}new Ajax.Autocompleter('{$htmlOptions['id']}', '{$divOptions['id']}', '";
     $script .= $this->Html->url($url) . "', {$options});";
     return "{$text}\n{$div}\n" . $this->Javascript->codeBlock($script);
 }
Ejemplo n.º 22
0
 public function link($title, $url = null, $options = array(), $confirmMessage = false)
 {
     if ($this->isAllowed($url)) {
         return parent::link($title, $url, $options, $confirmMessage);
     }
     return '';
 }
 /**
  * (non-PHPdoc)
  * @see GalleryHelper::get_markup()
  */
 public function get_markup()
 {
     if (empty($this->images)) {
         return '';
     }
     if (empty($this->unid)) {
         $this->calculate_unique();
     }
     $this->load_assets();
     $list = array();
     foreach ($this->images as $k => $image) {
         $list[] = $this->render_element($k);
     }
     $first_image = array_shift($list);
     /*$src = '/images/ajax-loader.gif';
     		if(file_exists(get_stylesheet_directory().$src))
     			$src = get_stylesheet_directory_uri().$src;
     		
     		if(file_exists(get_template_directory().$src))
     			$src = get_template_directory_uri().$src;
     		
     		$first_image = HtmlHelper::image($src, array('id'=>'loading-gif'));*/
     $script = HtmlHelper::script(json_encode($list), array('id' => 'script_' . $this->unid));
     $defaults = array('id' => $this->unid, 'class' => 'cycle-slideshow', 'data-cycle-loader' => 'true', 'data-cycle-progressive' => '#script_' . $this->unid);
     return HtmlHelper::div($first_image . $script, wp_parse_args($this->cycle_attrs, $defaults));
 }
Ejemplo n.º 24
0
 public function image($path, $options = array())
 {
     if (empty($path)) {
         $path = 'no_image.png';
     } else {
         if (isset($options['section'])) {
             switch ($options['section']) {
                 case 'UserProfile':
                     $path = Configure::read('ImagePath.UserProfile') . $path;
                     break;
                 case 'AdvisorProfile':
                     $path = Configure::read('ImagePath.AdvisorProfile') . $path;
                     break;
                 case 'temp':
                     $path = Configure::read('ImagePath.temp') . $path;
                     break;
                 case 'Job':
                     $path = Configure::read('ImagePath.Job') . $path;
                     break;
                 case 'BusinessField':
                     $path = Configure::read('ImagePath.BusinessField') . $path;
                     break;
             }
         }
     }
     return parent::image($path, $options);
 }
Ejemplo n.º 25
0
 function __toString()
 {
     $json_config = JsonHelper::encode($this->config);
     $this->afterHTML = HtmlHelper::inlineJavascript('jQuery(function(){$("#' . $this->getId() . '").datepicker(' . $json_config . ')});');
     $this->setAttribute('class', 'form_input_text form_ycalendar');
     return parent::__toString();
 }
Ejemplo n.º 26
0
 function __toString()
 {
     if ($this->countElements() < $this->min_inputs) {
         for ($i = 0; $i < $this->min_inputs - $this->countElements(); $i++) {
             $this->add();
         }
     }
     $html = new HtmlHelper();
     $output = $html->javascript('/widgets/custom/textlist.js');
     $output .= $html->css('/widgets/custom/textlist.css');
     $output .= '<div class="phaxsi-textlist" data-max="' . $this->max_inputs . '" data-callback="' . $this->on_insert . '" data-name="' . $this->_name . '">';
     $output .= '<div>' . $this->toString() . '</div>';
     $output .= $this->max_inputs == 0 || count($this->_elements) < $this->max_inputs ? $html->absoluteLink($this->link_text, 'javascript:void(0)', '') : '';
     $output .= '</div>';
     return $output;
 }
Ejemplo n.º 27
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);
 }
Ejemplo n.º 28
0
 /**
  *
  * @param string $path
  * @param array  $options
  * @return @return string completed img tag
  */
 public function image($path, $options = array())
 {
     if (preg_match('!^http://a[0-9]+\\.twimg\\.com/!', $path) && env('HTTPS')) {
         $path = preg_replace('!^http://a[0-9]+\\.twimg\\.com/!', 'https://s3.amazonaws.com/twitter_production/', $path);
     }
     return $this->Html->image($path, $options);
 }
Ejemplo n.º 29
0
 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;
 }
Ejemplo n.º 30
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);
 }