Beispiel #1
0
 /**
  * Retrieve a JSON object containing autocomplete suggestions for existing users.
  */
 public function action_tag()
 {
     $string = $this->request->param('string', FALSE);
     $type = $this->request->param('type', 'blog');
     // The user enters a comma-separated list of tags. We only autocomplete the last tag.
     $tags_typed = Tags::explode($string);
     $tag_last = UTF8::strtolower(array_pop($tags_typed));
     $matches = array();
     if (!empty($tag_last)) {
         $query = DB::select('name')->from('tags')->where('name', 'LIKE', $tag_last . '%')->where('type', '=', $type);
         // Do not select already entered terms.
         if (!empty($tags_typed)) {
             $query->where('name', 'NOT IN', $tags_typed);
         }
         $result = $query->limit('10')->execute();
         $prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
         foreach ($result as $tag) {
             $n = $tag['name'];
             // Tag names containing commas or quotes must be wrapped in quotes.
             if (strpos($tag['name'], ',') !== FALSE or strpos($tag['name'], '"') !== FALSE) {
                 $n = '"' . str_replace('"', '""', $tag['name']) . '"';
             } else {
                 $matches[$prefix . $n] = Text::plain($tag['name']);
             }
         }
     }
     $this->response->body(JSON::encode($matches));
 }
Beispiel #2
0
 /**
  * Load the active theme.
  *
  * This is called at bootstrap time.
  * We will only ever have one theme active for any given request.
  *
  * @uses Kohana::modules
  */
 public static function load_themes()
 {
     $config = Config::load('site');
     self::$themes = self::available(FALSE);
     //set admin theme based on path info
     $path = ltrim(Request::detect_uri(), '/');
     Theme::$is_admin = $path == "admin" || !strncmp($path, "admin/", 6);
     if (Theme::$is_admin) {
         // Load the admin theme
         Theme::$active = $config->get('admin_theme', 'cerber');
     } else {
         // Load the site theme
         Theme::$active = $config->get('theme', 'cerber');
     }
     //Set mobile theme, if enabled and mobile request
     if (Request::is_mobile() and $config->get('mobile_theme', FALSE)) {
         // Load the mobile theme
         Theme::$active = $config->get('mobile_theme', 'cerber');
     }
     // Admins can override the site theme, temporarily. This lets us preview themes.
     if (User::is_admin() and isset($_GET['theme']) and $override = Text::plain($_GET['theme'])) {
         Theme::$active = $override;
     }
     //Finally set the active theme
     Theme::set_theme();
 }
Beispiel #3
0
 /**
  * Retrieve a JSON object containing autocomplete suggestions for existing aliases
  *
  * @uses  ACL::required
  * @uses  DB::select
  * @uses  Text::plain
  * @uses  JSON::encode
  */
 public function action_links()
 {
     ACL::required('administer menu');
     $string = $this->request->param('string', FALSE);
     $matches = array();
     if ($string) {
         $result = DB::select('alias')->from('paths')->where('alias', 'LIKE', $string . '%')->limit('10')->execute();
         foreach ($result as $link) {
             $matches[$link['alias']] = Text::plain($link['alias']);
         }
     }
     $this->response->body(JSON::encode($matches));
 }
Beispiel #4
0
 /**
  * doctestを取得
  * @param string $src doctestを含む文字列
  * @param string $self_class 定義されているクラス名
  * @param string $class_package 定義されているパッケージ名
  * @param integer $offset 開始行
  * @return self{}
  */
 public static function get($src, $self_class, $class_package, $offset = 0)
 {
     $doctest = array();
     if (preg_match_all("/\\/\\*\\*\\*.+?\\*\\//s", $src, $comments, PREG_OFFSET_CAPTURE)) {
         foreach ($comments[0] as $value) {
             if (isset($value[0][5]) && $value[0][5] != "*") {
                 $test_block = str_replace(array("self::", "new self("), array($self_class . "::", "new " . $self_class . "("), preg_replace("/^[\\s]*\\*[\\s]{0,1}/m", "", str_replace(array("/" . "***", "*" . "/"), "", $value[0])));
                 $test_object = new self(preg_match("/^[\\s]*#(.+)/", $test_block, $match) ? trim($match[1]) : null, $class_package);
                 $test_object->test(Text::plain($test_block));
                 $doctest[$offset + substr_count(substr($src, 0, $value[1]), "\n")] = $test_object;
             }
         }
     }
     return $doctest;
 }
Beispiel #5
0
 /**
  * List tags
  *
  * @uses  Request::is_datatables
  * @uses  ORM::dataTables
  * @uses  Text::plain
  * @uses  HTML::icon
  * @uses  Route::url
  * @uses  Route::get
  * @uses  Assets::popup
  */
 public function action_list()
 {
     Assets::popup();
     $is_datatables = Request::is_datatables();
     if ($is_datatables) {
         $tags = ORM::factory('tag');
         $this->_datatables = $tags->dataTables(array('name', 'id', 'type'));
         foreach ($this->_datatables->result() as $tag) {
             $this->_datatables->add_row(array(Text::plain($tag->name), HTML::anchor($tag->url, $tag->url), Text::plain($tag->type), HTML::icon($tag->edit_url, 'fa-edit', array('class' => 'btn btn-sm btn-default action-edit', 'title' => __('Edit Tag'))) . ' ' . HTML::icon($tag->delete_url, 'fa-trash-o', array('class' => 'btn btn-sm btn-default action-delete', 'title' => __('Delete Tag'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-tags'))));
         }
     }
     $this->title = __('Tags');
     $url = Route::url('admin/tag', array('action' => 'list'), TRUE);
     $view = View::factory('admin/tag/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('url', $url);
     $this->response->body($view);
 }
Beispiel #6
0
 /**
  * List user roles
  *
  * @uses  Request::is_datatables
  * @uses  ORM::dataTables
  */
 public function action_list()
 {
     $is_datatables = Request::is_datatables();
     if ($is_datatables) {
         $roles = ORM::factory('role');
         $this->_datatables = $roles->dataTables(array('name', 'description', 'special'));
         foreach ($this->_datatables->result() as $role) {
             $this->_datatables->add_row(array(Text::plain($role->name), Text::plain($role->description), $role->special ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-ban"></i>', $role->special ? HTML::icon($role->perm_url, 'fa-lock', array('title' => __('Edit Permissions'))) : HTML::icon($role->edit_url, 'fa-edit', array('title' => __('Edit Role'))) . '&nbsp;' . HTML::icon($role->delete_url, 'fa-trash-o', array('title' => __('Delete Role'))) . '&nbsp;' . HTML::icon($role->perm_url, 'fa-lock', array('title' => __('Edit Permissions')))));
         }
     }
     $this->title = __('Roles');
     $add_url = Route::get('admin/role')->uri(array('action' => 'add'));
     $url = Route::url('admin/role', array('action' => 'list'), TRUE);
     $view = View::factory('admin/role/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url);
     $this->response->body($view);
 }
Beispiel #7
0
 /**
  * Displays a list of all users
  *
  * @uses  Request::is_datatables
  * @uses  ORM::dataTables
  * @uses  Text::plain
  * @uses  Text::auto_link
  * @uses  User::roles
  * @uses  HTML::anchor
  * @uses  HTML::icon
  * @uses  Route::get
  * @uses  Route::url
  * @uses  Date::formatted_time
  * @uses  Assets::popup
  */
 public function action_list()
 {
     $is_datatables = Request::is_datatables();
     if ($is_datatables) {
         $users = ORM::factory('user');
         // @todo fix dummy id column for roles to match the column order
         $this->_datatables = $users->dataTables(array('name', 'mail', 'created', 'login', 'id', 'status'));
         foreach ($this->_datatables->result() as $user) {
             $this->_datatables->add_row(array(HTML::anchor($user->url, Text::plain($user->nick)), Text::auto_link($user->mail), Date::formatted_time($user->created, 'M d, Y'), $user->login > 0 ? Date::formatted_time($user->login, 'M d, Y') : __('Never'), User::roles($user), $user->status == 1 ? '<span class="status-active"><i class="fa fa-check-circle"></i></span>' : '<span class="status-blocked"><i class="fa fa-ban"></i></span>', HTML::icon(Route::get('admin/user')->uri(array('action' => 'edit', 'id' => $user->id)), 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit User'))) . '&nbsp;' . HTML::icon(Route::get('admin/permission')->uri(array('action' => 'user', 'id' => $user->id)), 'fa-key', array('class' => '', 'title' => __('Edit Permission'))) . '&nbsp;' . HTML::icon($user->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete User'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-users'))));
         }
     }
     Assets::popup();
     $this->title = __('Users');
     $url = Route::url('admin/user', array('action' => 'list'), TRUE);
     $view = View::factory('admin/user/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('url', $url);
     $this->response->body($view);
 }
Beispiel #8
0
 /**
  * List menus
  *
  * @uses  ORM::reset
  * @uses  ORM::dataTables
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  Route::url
  * @uses  Assets::popup
  * @uses  Request::is_datatables
  * @uses  Text::plain
  * @uses  HTML::icon
  */
 public function action_list()
 {
     Assets::popup();
     $is_datatables = Request::is_datatables();
     $menus = ORM::factory('menu')->where('lft', '=', 1);
     if ($is_datatables) {
         $this->_datatables = $menus->dataTables(array('title', 'descp'));
         foreach ($this->_datatables->result() as $menu) {
             $this->_datatables->add_row(array(Text::plain($menu->title) . '<div class="description">' . Text::plain($menu->descp) . '</div>', HTML::icon($menu->list_items_url, 'fa-th-list', array('class' => 'action-list', 'title' => __('List Links'))), HTML::icon($menu->add_item_url, 'fa-plus', array('class' => 'action-add', 'title' => __('Add Link'))), HTML::icon($menu->edit_url, 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit Menu'))), HTML::icon($menu->delete_url, 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete Menu'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-menus'))));
         }
     }
     $this->title = __('Menus');
     $add_url = Route::get('admin/menu')->uri(array('action' => 'add'));
     $url = Route::url('admin/menu', array('action' => 'list'), TRUE);
     $view = View::factory('admin/menu/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url);
     $this->response->body($view);
 }
Beispiel #9
0
 /**
  * List Category Groups
  *
  * @uses  Assets::popup
  * @uses  Request::is_datatables
  * @uses  Text::plain
  * @uses  HTML::icon
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  Route::url
  */
 public function action_list()
 {
     Assets::popup();
     $is_datatables = Request::is_datatables();
     $terms = ORM::factory('term')->where('lft', '=', 1);
     if ($is_datatables) {
         $this->_datatables = $terms->dataTables(array('name', 'description'));
         foreach ($this->_datatables->result() as $term) {
             $this->_datatables->add_row(array(Text::plain($term->name) . '<div class="description">' . Text::plain($term->description) . '</div>', HTML::icon(Route::get('admin/term')->uri(array('action' => 'list', 'id' => $term->id)), 'fa-th-list', array('class' => 'action-list', 'title' => __('List Categories'))), HTML::icon(Route::get('admin/term')->uri(array('action' => 'add', 'id' => $term->id)), 'fa-plus', array('class' => 'action-add', 'title' => __('Add Category'))), HTML::icon(Route::get('admin/taxonomy')->uri(array('action' => 'edit', 'id' => $term->id)), 'fa-edit', array('class' => 'action-edit', 'title' => __('Edit Group'))), HTML::icon(Route::get('admin/taxonomy')->uri(array('action' => 'delete', 'id' => $term->id)), 'fa-trash-o', array('class' => 'action-delete', 'title' => __('Delete Group'), 'data-toggle' => 'popup', 'data-table' => '#admin-list-vocabs'))));
         }
     }
     $this->title = __('Category Groups');
     $add_url = Route::get('admin/taxonomy')->uri(array('action' => 'add'));
     $url = Route::url('admin/taxonomy', array('action' => 'list'), TRUE);
     $view = View::factory('admin/taxonomy/list')->bind('datatables', $this->_datatables)->set('is_datatables', $is_datatables)->set('add_url', $add_url)->set('url', $url);
     $this->response->body($view);
 }
Beispiel #10
0
 /**
  * Sending mails
  *
  * @since 1.0.0  First time this method was introduced
  * @since 1.1.0  Added jQuery Textarea Characters Counter Plugin
  *
  * @link  http://roy-jin.appspot.com/jsp/textareaCounter.jsp
  *
  * @uses  Request::query
  * @uses  Route::get
  * @uses  Route::uri
  * @uses  URL::query
  * @uses  URL::site
  * @uses  Validation::rule
  * @uses  Config::get
  * @uses  Config::load
  * @uses  Assets::js
  */
 public function action_mail()
 {
     $this->title = __('Contact us');
     $config = Config::load('contact');
     Assets::js('textareaCounter', 'media/js/jquery.textareaCounter.plugin.js', array('jquery'), FALSE, array('weight' => 10));
     Assets::js('greet/form', 'media/js/greet.form.js', array('textareaCounter'), FALSE, array('weight' => 15));
     //Add schema.org support
     $this->schemaType = 'ContactPage';
     // Set form destination
     $destination = !is_null($this->request->query('destination')) ? array('destination' => $this->request->query('destination')) : array();
     // Set form action
     $action = Route::get('contact')->uri(array('action' => $this->request->action())) . URL::query($destination);
     // Get user
     $user = User::active_user();
     // Set mail types
     $types = $config->get('types', array());
     $view = View::factory('contact/form')->set('destination', $destination)->set('action', $action)->set('config', $config)->set('types', $types)->set('user', $user)->bind('post', $post)->bind('errors', $this->_errors);
     // Initiate Captcha
     if ($config->get('use_captcha', FALSE) and !$this->_auth->logged_in()) {
         $captcha = Captcha::instance();
         $view->set('captcha', $captcha);
     }
     if ($this->valid_post('contact')) {
         $post = Validation_Contact::factory($this->request->post());
         if ($post->check()) {
             // Create the email subject
             $subject = __('[:category] :subject', array(':category' => $types[$post['category']], ':subject' => Text::plain($post['subject'])));
             // Create the email body
             $body = View::factory('email/contact')->set('name', $post['name'])->set('body', $post['body'])->set('config', Config::load('site'))->render();
             // Create an email message
             $email = Email::factory()->to(Text::plain($this->_config->get('site_email', '*****@*****.**')), __('Webmaster :site', array(':site' => Template::getSiteName())))->subject($subject)->from($post['email'], Text::plain($post['name']))->message($body, 'text/html');
             // @todo message type should be configurable
             // Send the message
             $email->send();
             Log::info(':name sent an e-mail regarding :cat', array(':name' => Text::plain($post['name']), ':cat' => $types[$post['category']]));
             Message::success(__('Your message has been sent.'));
             // Always redirect after a successful POST to prevent refresh warnings
             $this->request->redirect(Route::get('contact')->uri(), 200);
         } else {
             $this->_errors = $post->errors('contact', TRUE);
         }
     }
     $this->response->body($view);
 }
Beispiel #11
0
 /**
  * Reading data from inaccessible properties
  *
  * @param   string  $field
  * @return  mixed
  *
  * @uses  Text::plain
  * @uses  Text::markup
  * @uses  Route::get
  * @uses  Route::uri
  */
 public function __get($field)
 {
     switch ($field) {
         case 'subject':
             return Text::plain(parent::__get('subject'));
         case 'body':
             return Text::markup($this->rawbody, $this->format);
         case 'rawsubject':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('subject');
         case 'rawbody':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('body');
         case 'url':
             return Route::get('user/message')->uri(array('id' => $this->id, 'action' => 'view'));
         case 'delete_url':
             return Route::get('user/message')->uri(array('id' => $this->id, 'action' => 'delete'));
         default:
             return parent::__get($field);
     }
 }
Beispiel #12
0
 /**
  * Reading data from inaccessible properties
  *
  * @param   string  $field
  * @return  mixed
  *
  * @uses  Text::plain
  * @uses  Text::markup
  * @uses  HTML::links
  * @uses  Path::load
  * @uses  Route::get
  * @uses  Route::uri
  */
 public function __get($field)
 {
     switch ($field) {
         case 'title':
             return Text::plain(parent::__get('title'));
             break;
         case 'teaser':
             return Text::markup($this->rawteaser, $this->format);
             break;
         case 'body':
             return Text::markup($this->rawbody, $this->format);
             break;
         case 'terms_form':
             return $this->terms->find()->id;
             break;
         case 'tags_form':
             return $this->tags->find_all()->as_array('id', 'name');
             break;
         case 'taxonomy':
             return HTML::links($this->terms->find_all(), array('class' => 'nav nav-pills pull-right'));
             break;
         case 'tagcloud':
             return HTML::links($this->tags->find_all(), array('class' => 'nav nav-pills'));
             break;
         case 'links':
             return HTML::links($this->links(), array('class' => 'links inline'));
             break;
         case 'rawtitle':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('title');
             break;
         case 'rawteaser':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('teaser');
             break;
         case 'rawbody':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('body');
             break;
         case 'rawurl':
             return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'view'));
             break;
         case 'rawimage':
             // Raw fields without path. Usage: during edit or etc!
             return parent::__get('image');
             break;
         case 'url':
             // Model specific links; view, edit, delete url's
             return ($path = Path::load($this->rawurl)) ? $path['alias'] : $this->rawurl;
             break;
         case 'edit_url':
             return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'edit'));
             break;
         case 'delete_url':
             return Route::get($this->type)->uri(array('id' => $this->id, 'action' => 'delete'));
             break;
         case 'image':
             return $this->rawimage ? $this->_image_url . $this->rawimage : NULL;
             break;
         case 'count_comments':
             return (int) DB::select(array(DB::expr('COUNT(*)'), 'mycount'))->from('comments')->where('status', '=', 'publish')->where('post_id', '=', $this->id)->execute()->get('mycount');
             break;
     }
     return parent::__get($field);
 }
Beispiel #13
0
 /**
  * Renders the HTML output for the menu
  *
  * @param   array   $attributes  Associative array of html attributes [Optional]
  * @param   array   $items       The parent item's array, only used internally [Optional]
  *
  * @return  string  HTML unordered list
  */
 public function render(array $attributes = NULL, array $items = NULL)
 {
     static $i;
     $items = empty($items) ? $this->items : $items;
     $attributes = empty($attributes) ? $this->attributes : $attributes;
     if (empty($items)) {
         return;
     }
     $i++;
     //This attribute detects we're in nav or widget for styling
     $is_widget = isset($attributes['widget']);
     if ($is_widget) {
         unset($attributes['widget']);
     }
     $attributes['class'] = empty($attributes['class']) ? 'level-' . $i : $attributes['class'] . ' level-' . $i;
     $menu = '<ul' . HTML::attributes($attributes) . '>';
     $num_items = count($items);
     $_i = 1;
     foreach ($items as $key => $item) {
         $has_children = count($item['children']);
         $classes = NULL;
         $attributes = array();
         $caret = NULL;
         // Add first, last and parent classes to the list of links to help out themers.
         if ($_i == 1) {
             $classes[] = 'first';
         }
         if ($_i == $num_items) {
             $classes[] = 'last';
         }
         if ($has_children) {
             $classes[] = 'parent dropdown';
             $attributes[] = 'dropdown-toggle collapsed';
             if ($i == 2) {
                 $classes[] = 'dropdown-submenu';
             }
         }
         // Check if the menu item URI is or contains the current URI
         if (HTML::is_active($item['url'])) {
             $classes[] = 'active';
             $attributes[] = 'active';
         }
         if (!empty($classes)) {
             $classes = HTML::attributes(array('class' => implode(' ', $classes)));
         }
         if (!empty($attributes)) {
             $attributes = array('class' => implode(' ', $attributes));
         }
         $id = HTML::attributes(array('id' => 'menu-' . $key));
         //Twitter bootstrap attributes
         if ($has_children) {
             $attributes['data-toggle'] = 'dropdown';
             $item['url'] = '#';
             $caret = $i == 2 ? '' : '<b class="caret"></b>';
             $class = 'dropdown-menu';
         }
         //Twitter bootstrap use collapse for widget menu chlidren
         if ($has_children && $is_widget) {
             $attributes['data-toggle'] = 'collapse';
             $attributes['data-parent'] = '#menu-' . $key;
             $item['url'] = '#collapse-' . $key;
             $class = 'panel-collapse collapse';
             $caret = $i == 2 ? '' : '<i class="fa fa-chevron-down submenu"></i>';
         }
         //set title
         $title = isset($item['image']) ? '<i class="fa fa-fw ' . $item['image'] . '"></i>' : '';
         // localize item menu
         $title .= '<span>' . Text::plain(__($item['title'])) . $caret . '</span>';
         if ($item['descp'] && !empty($item['descp'])) {
             // localize item desc
             $title .= '<span class="menu-descp">' . Text::plain(__($item['descp'])) . '</span>';
         }
         $menu .= '<li' . $classes . '  ' . $id . '>' . HTML::anchor($item['url'], $title, $attributes);
         if ($has_children) {
             $menu .= $this->render(array('class' => $class, 'id' => 'collapse-' . $key), $item['children']);
         }
         $_i++;
         $menu .= '</li> ';
     }
     $menu .= '</ul>';
     $i--;
     return $menu;
 }
Beispiel #14
0
            echo __('Warning! Give to trusted roles only; this permission has security implications.');
            ?>
									</cite>
								<?php 
        }
        ?>
							</div>
						</div>
	
					</td>
					<?php 
        foreach ($roles as $i => $role) {
            ?>
						<td class="role-checkbox">
							<?php 
            echo Form::checkbox("roles[{$role->id}][{$key}{$perm}{$i}][name]", Text::plain($perm), isset($role_perms[$role->id][$perm]));
            ?>
		
							<?php 
            echo Form::hidden("roles[{$role->id}][{$key}{$perm}{$i}][module]", $key);
            ?>
							<?php 
            echo Form::hidden("roles[{$role->id}][{$key}{$perm}{$i}][id]", $role->id);
            ?>
						</td>
					<?php 
        }
        ?>
					 </tr>
			<?php 
    }
Beispiel #15
0
							<td class="module-description-column">
								<div class="module-title-column">
									<strong><?php 
    echo Text::plain($module_info->title);
    ?>
</strong>
								</div>
								<div class="module-description">
									<p><?php 
    echo __($module_info->description);
    ?>
</p>
								</div>
								<div class="module-version">
									<?php 
    echo __('Version: %ver | By: :author', array('%ver' => Text::plain($module_info->version), ':author' => HTML::anchor($module_info->authorURL, __($module_info->author))));
    ?>
								</div>
							</td>
						</tr>
					<?php 
}
?>
					</tbody>
				</table>
				<?php 
echo Form::submit('modules', __('Save'), array('class' => 'btn btn-success pull-right'));
?>
			<?php 
echo Form::close();
?>
Beispiel #16
0
/**
 * ヒアドキュメントのようなテキストを生成する
 * 1行目のインデントに合わせてインデントが消去される
 * @param string $text
 * @return string
 */
function text($text)
{
    return Text::plain($text);
}
Beispiel #17
0
 public function action_delete()
 {
     if (!ACL::check('delete oaclient2')) {
         throw new HTTP_Exception_404('You have no permission to delete oauth2 clients.');
     }
     $id = (int) $this->request->param('id');
     $redirect = empty($this->redirect) ? Route::get('oauth2/client')->uri(array('action' => 'list')) : $this->redirect;
     $oaclient = ORM::factory('oaclient', $id);
     if (!$oaclient->loaded()) {
         Message::error(__('oaclient: doesn\'t exists!'));
         Kohana::$log->add(Log::ERROR, 'Attempt to delete non-existent oaclient');
         $this->request->redirect(Route::get('oauth2/client')->uri(array('action' => 'list')));
     }
     $clone_oaclient = clone $oaclient;
     if (!Access::oaclient('delete', $oaclient)) {
         // If the lead was not loaded, we return access denied.
         throw new HTTP_Exception_404('Attempt to non-existent oaclient.');
     }
     $this->title = __('Delete oaclient');
     $this->subtitle = Text::plain($oaclient->client_id);
     $form = View::factory('form/confirm')->set('action', $oaclient->delete_url)->set('title', $oaclient->client_id);
     // If deletion is not desired, redirect to post
     if (isset($_POST['no']) and $this->valid_post()) {
         $this->request->redirect('oauth2/client');
     }
     // If deletion is confirmed
     if (isset($_POST['yes']) and $this->valid_post()) {
         try {
             $oaclient->delete();
             Message::success(__('oaclient: :title deleted successfully', array(':title' => $clone_oaclient->client_id)));
             $this->request->redirect($redirect);
         } catch (Exception $e) {
             Message::error(__('oaclient: :title unable to delete the record', array(':title' => $clone_oaclient->client_id)));
             $this->request->redirect($redirect);
         }
     }
     $this->response->body($form);
 }
Beispiel #18
0
<div class="span3 footer-block">
    <?php 
if ($widget->show_title) {
    ?>
        <h4><?php 
    echo Text::plain($title);
    ?>
</h4>
    <?php 
}
?>
    <div class="footer-block-content">
	    <?php 
echo $content;
?>
    </div>
</div>
Beispiel #19
0
<h1><?php 
echo __('Hello!');
?>
</h1>

<p><?php 
echo __(':name sent a message using the contact form at :site.', array(':name' => Text::plain($name), ':site' => URL::site('contact', TRUE)));
?>
</p>

<?php 
echo Text::markup($body);
?>
<br>
<hr>
<p>
	<?php 
echo __('Best Regards');
?>
,<br>
	<?php 
echo $config->get('site_url', 'www.gleezcms.org');
?>
<br>
	<?php 
echo Template::getSiteName();
?>
</p>
Beispiel #20
0
 /**
  * Processes an HTML attribute value and ensures it doesn't contain an URL with a disallowed protocol
  *
  * Returns cleaned up and HTML-escaped version of `$string`
  *
  * @param   string   $string  The string with the attribute value
  * @param   boolean  $decode  Whether to decode entities in the $string? [Optional]
  * @return  string
  */
 private function xss_bad_protocol($string, $decode = TRUE)
 {
     // Get the plain text representation of the attribute value (i.e. its meaning).
     if ($decode) {
         $string = $this->decode_entities($string);
     }
     return Text::plain($this->strip_dangerous_protocols($string));
 }
Beispiel #21
0
				text-align: center;
			}
			.error_type {
				color: #4E8622;
			}
		</style>
	</head>
	<body>
		<h1 class="text_2"><span><?php 
echo __('Dang...  Access Denied!');
?>
</span></h1>
		<p class="reasons_big"><?php 
echo __('There\'s a lot of reasons why this page is <span class="error_type">403</span>.');
?>
</p>
		
		<p class="reasons_small">
			<?php 
echo __("You're not authorized to access <span>(:url)</span> page!", array(':url' => Text::plain($url)));
?>
		</p>
		
		<p class="solutions_text">
			<?php 
echo __("This page is only visible to authorized users.\n\t\t\t\t      <br>If you think this is an error, talk to the Site administrator!");
?>
		</p>
	</body>
</html>
Beispiel #22
0
					<?php 
    echo Form::weight('tid:' . $item['id'] . '[weight]', 0, array('class' => 'row-weight'));
    ?>
					<?php 
    echo Form::hidden('tid:' . $item['id'] . '[pid]', $item['pid'], array('class' => 'row-parent'));
    ?>
					<?php 
    echo Form::hidden('tid:' . $item['id'] . '[tid]', $item['id'], array('class' => 'row-id'));
    ?>
					<?php 
    echo Form::hidden('tid:' . $item['id'] . '[depth]', $item['lvl'], array('class' => 'term-depth'));
    ?>
				</td>
				<td>
					<p class="text text-muted"> <?php 
    echo Text::plain($item['description']);
    ?>
 </p>
				</td>
				<td class="action">
					<?php 
    echo HTML::anchor(Route::get('admin/term')->uri(array('action' => 'edit', 'id' => $item['id'])), '<i class="fa fa-edit"></i>', array('class' => 'btn btn-sm btn-default', 'title' => __('Edit Term')));
    ?>
					<?php 
    echo HTML::anchor(Route::get('admin/term')->uri(array('action' => 'delete', 'id' => $item['id'])), '<i class="fa fa-times"></i>', array('class' => 'btn btn-sm btn-default btn-danger', 'title' => __('Delete Term')));
    ?>
				</td>
			</tr>
		<?php 
}
?>
Beispiel #23
0
						<?php 
}
?>
					</div>
				</div>
				<hr>
				<div class="bio">
					<?php 
if ($user->bio) {
    ?>
						<div title="<?php 
    _e('Bio');
    ?>
">
							<p><?php 
    echo Text::plain($user->bio);
    ?>
</p>
						</div>
					<?php 
}
?>
				</div>
			</div>
		</div>
	</div>

	<div class="col-md-3 col-sm-4 col-xs-12 col-sidebar-right">
		<div class="list-group">
			<a href="#" class="list-group-item"><h3 class="pull-right"><i class="fa fa-sign-in"></i></h3>
				<h4 class="list-group-item-heading"><?php 
Beispiel #24
0
 /**
  * Reading data from inaccessible properties
  *
  * @param   string  $field
  * @return  mixed
  *
  * @uses    Text::plain
  * @uses    Text::markup
  * @uses    Route::get
  * @uses    Route::uri
  */
 public function __get($field)
 {
     switch ($field) {
         case 'title':
             return Text::plain(parent::__get('title'));
             break;
         case 'body':
             return Text::markup(parent::__get('body'), $this->format);
             break;
         case 'rawtitle':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('title');
             break;
         case 'rawbody':
             // Raw fields without markup. Usage: during edit or etc!
             return parent::__get('body');
             break;
         case 'url':
             // Model specific links; view, edit, delete url's.
             return Route::get('comment')->uri(array('id' => $this->id, 'action' => 'view'));
             break;
         case 'edit_url':
             // Model specific links; view, edit, delete url's.
             return Route::get('comment')->uri(array('id' => $this->id, 'action' => 'edit'));
             break;
         case 'delete_url':
             return Route::get('comment')->uri(array('id' => $this->id, 'action' => 'delete'));
             break;
     }
     return parent::__get($field);
 }
Beispiel #25
0
			}
		</style>
	</head>
	<body>
		<h1 class="text_2"><span><?php 
echo __('Dang...  Page not found!');
?>
</span></h1>
		<h1 class="text_2"><span><?php 
echo __('Whops, I think we are lost...!');
?>
</span></h1>
		<p class="reasons_big"><?php 
echo __('There\'s a lot of reasons why this page is <span class="error_type">404</span>.');
?>
</p>
		
		<p class="reasons_small">
			<?php 
echo __('The requested URL <span>(:url)</span> could not be found!', array(':url' => Text::plain($url)));
?>
		</p>
		
		<p class="solutions_text">
			<?php 
echo __("Maybe the page exists, but is only visible to authorized users.\n\t\t\t\t      <br>If you think this is an error, talk to the Site administrator!");
?>
		</p>
	</body>
</html>
Beispiel #26
0
 /**
  * Themed list of roles to print
  *
  * @param   ORM     $user  The user object
  * @return  string  html to display
  */
 public static function roles(ORM $user)
 {
     $roles = '<ul class="user-roles">';
     foreach ($user->roles() as $role) {
         $roles .= '<li>' . Text::plain($role) . '</li>';
     }
     $roles .= '</ul>';
     return $roles;
 }
Beispiel #27
0
 /**
  * Print out a themed set of tabs
  *
  * @param   array  $tabs        Tabs
  * @param   array  $attributes  Attributes, for example CSS class [Optional]
  *
  * @return  string Prepared HTML
  *
  * @uses    Text::plain
  */
 public static function tabs($tabs, $attributes = array('class' => 'tabs'))
 {
     $output = '';
     if (count($tabs) > 0) {
         $output = '<ul' . self::attributes($attributes) . '>';
         $num_links = count($tabs);
         $i = 1;
         foreach ($tabs as $tab) {
             $class = 'tab-' . $i;
             if (isset($tab['active']) or isset($tab['link']) and self::is_active($tab['link'])) {
                 $class .= ' active';
             }
             // Add first, last and active classes to the list of links to help out themers.
             if ($i == 1) {
                 $class .= ' first';
             }
             if ($i == $num_links) {
                 $class .= ' last';
             }
             $output .= '<li' . self::attributes(array('class' => $class)) . '>';
             // Sanitized link text
             $tab['text'] = Text::plain($tab['text']);
             if (empty($tab['link'])) {
                 $output .= '<span class="active">' . $tab['text'] . '</span>';
             } else {
                 $output .= self::anchor($tab['link'], $tab['text']);
             }
             $i++;
             $output .= "</li>" . PHP_EOL;
         }
         $output .= '</ul>';
     }
     return $output;
 }
Beispiel #28
0
 /**
  * Adds a message to the log
  *
  * Replacement values must be passed in to be
  * replaced using [strtr](http://php.net/strtr).
  *
  * Usage:
  * ~~~
  * $log->add(Log::ERROR, 'Could not locate user: :user', array(':user' => $user->name));
  * ~~~
  *
  * @param   string  $level       Level of message
  * @param   string  $message     Message body
  * @param   array   $values      Values to replace in the message [Optional]
  * @param   array   $additional  Additional custom parameters to supply to the log writer [Optional]
  * @return  Log
  *
  * @uses    Date::formatted_time
  * @uses    Date::$timestamp_format
  * @uses    Date::$timezone
  * @uses    Request::current
  * @uses    Request::initial
  * @uses    Request::uri
  * @uses    Request::detect_uri
  * @uses    Request::$client_ip
  * @uses    Request::$user_agent
  * @uses    Text::plain
  */
 public function add($level, $message, array $values = NULL, array $additional = NULL)
 {
     if ($values) {
         // Insert the values into the message
         $message = strtr($message, $values);
     }
     if (isset($additional['exception'])) {
         $trace = $additional['exception']->getTrace();
     } else {
         // Older PHP version don't have 'DEBUG_BACKTRACE_IGNORE_ARGS',
         // so manually remove the args from the backtrace
         if (!defined('DEBUG_BACKTRACE_IGNORE_ARGS')) {
             $trace = array_map(function ($item) {
                 unset($item['args']);
                 return $item;
             }, array_slice(debug_backtrace(FALSE), 1));
         } else {
             $trace = array_slice(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS), 1);
         }
     }
     is_null($additional) or $additional = array();
     $request = Request::current();
     $uri = '';
     if ($request instanceof Request) {
         $uri = Request::initial()->uri();
     } elseif (!Kohana::$is_cli) {
         $uri = Request::detect_uri();
     }
     // Create a new message and timestamp it
     $this->_messages[] = array('time' => Date::formatted_time('now', Date::$timestamp_format, Date::$timezone), 'level' => $level, 'body' => $message, 'trace' => $trace, 'file' => isset($trace[0]['file']) ? $trace[0]['file'] : NULL, 'line' => isset($trace[0]['line']) ? $trace[0]['line'] : NULL, 'class' => isset($trace[0]['class']) ? $trace[0]['class'] : NULL, 'function' => isset($trace[0]['function']) ? $trace[0]['function'] : NULL, 'additional' => $additional, 'hostname' => Request::$client_ip, 'user_agent' => Request::$user_agent, 'referer' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '', 'url' => Text::plain($uri));
     if (Log::$write_on_add) {
         // Write logs as they are added
         $this->write();
     }
     return $this;
 }
Beispiel #29
0
 private static function parse_var(Tag $tag)
 {
     if ($tag->is_param('class')) {
         $var_value = array();
         foreach ($tag->in('arg') as $arg) {
             $var_value[] = $arg->in_param('value', Text::plain($arg->value()));
         }
     } else {
         $var_value = $tag->in_param('value', Text::plain($tag->value()));
     }
     return array('name' => $tag->in_param('name'), 'value' => $var_value, 'class' => $tag->in_param('class'), 'method' => $tag->in_param('method'));
 }
Beispiel #30
0
    /**
     * クラスファイルからgettext文字列を抜き出してpotファイルを作成する
     * @param string $path
     * @param string $lc_messages_path
     */
    public static function po_generate($path, $lc_messages_path)
    {
        $messages = array();
        foreach (File::ls($path, true) as $file) {
            if ($file->isClass()) {
                ob_start();
                include_once $file->fullname();
                Rhaco::import($file->oname());
                ob_get_clean();
                $ref = Info::reflection($file->oname());
                foreach ($ref->methods as $method) {
                    foreach ($method->gettext as $text) {
                        $messages[$text->str]["#: " . str_replace($path, "", $file->fullname()) . ":" . $text->line] = true;
                    }
                }
            }
        }
        ksort($messages, SORT_STRING);
        $output_src = sprintf(Text::plain('
						# SOME DESCRIPTIVE TITLE.
						# Copyright (C) YEAR THE PACKAGE\'S COPYRIGHT HOLDER
						# This file is distributed under the same license as the PACKAGE package.
						# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
						#
						#, fuzzy
						msgid ""
						msgstr ""
						"Project-Id-Version: PACKAGE VERSION\\n"
						"Report-Msgid-Bugs-To: \\n"
						"POT-Creation-Date: %s\\n"
						"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"
						"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n"
						"Language-Team: LANGUAGE <*****@*****.**>\\n"
				'), date("Y-m-d H:iO")) . "\n\n";
        foreach ($messages as $str => $lines) {
            $output_src .= "\n" . implode("\n", array_keys($lines)) . "\n";
            $output_src .= "msgid \"" . $str . "\"\n";
            $output_src .= "msgstr \"\"\n";
        }
        File::write(File::absolute($lc_messages_path, "messages.pot"), $output_src);
        //Rhaco::import("ext.Setup");
        //Setup::po_generate(dirname(__FILE__),Rhaco::selfpath()."/resources/locale/");
        //Setup::mo_generate(Rhaco::selfpath()."/resources/locale/");
        //Test::each_flush();
    }