Example #1
0
function mixkeyword($contentsource)
{
    $keywordsdata = new Keywords();
    $keywordslist = $keywordsdata->GetKeywordsList();
    $replacedarray = array();
    $matchnum = 0;
    if (count($keywordslist) > 0) {
        foreach ($keywordslist as $keywords) {
            if (preg_match_all("/(<a[^>]+>.*?<\\/a>)|(<img[^>]+>)|<strong>.*?<\\/strong>|<h[1-6]>.*?<\\/h[1-6]>/i", $contentsource, $matches, PREG_SET_ORDER)) {
                foreach ($matches as $match) {
                    $contentsource = str_replace($match[0], "<link>" . $matchnum . "</link>", $contentsource);
                    $replacedarray[$matchnum] = $match[0];
                    $matchnum++;
                }
            }
            if ($keywords->url != $cururl) {
                $patterns = "/(?<!<link>){$keywords->name}(?!<\\/link>)/i";
                $replacements = '<a href="' . $keywords->url . '">' . $keywords->name . '</a>';
                $contentsource = preg_replace($patterns, $replacements, $contentsource, 1);
            } else {
                $patterns = "/(?<!<link>){$keywords->name}(?!<\\/link>)/i";
                $replacements = '<strong>' . $keywords->name . '</strong>';
                $contentsource = preg_replace($patterns, $replacements, $contentsource, 1);
            }
        }
    }
    if (preg_match_all("/(?<=<link>)\\d+(?=<\\/link>)/", $contentsource, $matches, PREG_SET_ORDER)) {
        foreach ($matches as $match) {
            $contentsource = str_replace("<link>" . $match[0] . "</link>", $replacedarray[$match[0]], $contentsource);
        }
    }
    return $contentsource;
}
Example #2
0
 function getInstance()
 {
     if (!isset(self::$instance[get_class()])) {
         self::$instance = new Keywords();
     }
     return self::$instance;
 }
Example #3
0
 /**
  * @return Keywords
  */
 public function keywords()
 {
     if (null == $this->keywords) {
         $this->keywords = Keywords::query()->where('keywordable_type = :type:', ['type' => get_class($this)])->andWhere('keywordable_id = :id:', ['id' => $this->id])->execute()->getFirst();
     }
     return $this->keywords;
 }
Example #4
0
 public static function getKeywords($searchterm)
 {
     $hits = NULL;
     // if the static variable $ch is not initialized yet, do it now
     if (!isset(self::$ch)) {
         self::$ch = curl_init();
     }
     // Set our curl options for this request
     curl_setopt(self::$ch, CURLOPT_URL, 'http://clients1.google.com/complete/search?hl=en&gl=us&q=' . urlencode(trim($searchterm)));
     curl_setopt(self::$ch, CURLOPT_RETURNTRANSFER, TRUE);
     // Run the curl request
     $fc = curl_exec(self::$ch);
     // Filter out the Google Javascript API wrapping
     if (preg_match('/window.google.ac.h\\((.+?)\\)/', $fc, $results)) {
         // Decode the array as JSON
         $content = json_decode($results[1]);
         // Loop through each search result
         foreach ($content[1] as $result) {
             // Strip the commas and " results" from the number of hits returned
             $value = str_replace(array(',', ' results'), '', $result[1]);
             // Create a key in $hits named by the search result, with the number of hits as the value
             $hits[$result[0]] = $value;
         }
         // Confirm we actually found hits
         if (is_array($hits)) {
             // Sort the array by the number of hits, as a number, in reverse order
             arsort($hits, SORT_NUMERIC);
             return $hits;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
 public function run()
 {
     Keywords::create(array('id' => 1, 'Keyword' => 'Provider', 'alias' => 'Provider'));
     Keywords::create(array('id' => 2, 'Keyword' => 'User', 'alias' => 'User'));
     Keywords::create(array('id' => 3, 'Keyword' => 'Taxi', 'alias' => 'Taxi'));
     Keywords::create(array('id' => 4, 'Keyword' => 'Trip', 'alias' => 'Trip'));
     Keywords::create(array('id' => 5, 'Keyword' => '$', 'alias' => 'Currency'));
     Keywords::create(array('id' => 6, 'Keyword' => 'total_trip', 'alias' => '1'));
     Keywords::create(array('id' => 7, 'Keyword' => 'cancelled_trip', 'alias' => '2'));
     Keywords::create(array('id' => 8, 'Keyword' => 'total_payment', 'alias' => '3'));
     Keywords::create(array('id' => 9, 'Keyword' => 'completed_trip', 'alias' => '4'));
     Keywords::create(array('id' => 10, 'Keyword' => 'card_payment', 'alias' => '5'));
     Keywords::create(array('id' => 11, 'Keyword' => 'credit_payment', 'alias' => '6'));
 }
Example #6
0
 protected function update_search_index($poll, array $options = null)
 {
     // Load the search index model
     $this->load->model('search/search_index_m');
     $options_array = null;
     $options_string = null;
     if (!empty($options)) {
         foreach ($options as $option) {
             $options_array[] = preg_replace('/[^a-z0-9]+/i', ' ', $option['title']);
         }
     }
     $options_string = $options_array ? implode(', ', $options_array) : null;
     $this->search_index_m->index('polls', 'polls:poll', 'polls:polls', $poll['id'], 'polls/' . $poll['slug'], $poll['title'], $poll['description'], array('cp_edit_uri' => 'admin/polls/edit/' . $poll['id'], 'cp_delete_uri' => 'admin/polls/delete/' . $poll['id'], 'keywords' => Keywords::process($options_string)));
 }
Example #7
0
 public function pre_output($input, $data)
 {
     // if we want an array, format it correctly
     if (isset($data['return_type']) and $data['return_type'] === 'array') {
         $keyword_array = Keywords::get_array($input);
         $keywords = array();
         $total = count($keyword_array);
         foreach ($keyword_array as $key => $value) {
             $keywords[] = array('count' => $key, 'total' => $total, 'is_first' => $key == 0, 'is_last' => $key == $total - 1, 'keyword' => $value);
         }
         return $keywords;
     }
     // otherwise return it as a string
     return Keywords::get_string($input);
 }
Example #8
0
 public function offsetGet($offset)
 {
     $helper = new ListsHelper();
     if ($offset) {
         $keys = Keywords::getKeyCodes();
         $exp = '[';
         foreach ($keys as $id => $code) {
             $exp .= '\\' . $code;
         }
         $exp .= ']';
         preg_match('/^(' . $exp . ')(.*?)$/', $offset, $matches);
         if (count($matches)) {
             $exists = array_search($matches[1], $keys);
             if ($exists !== false) {
                 if ($matches[2]) {
                     $helper->getTasksByKeyword($matches[2], $exists);
                     #FB::info($helper, 'Tasks for Keyword');
                 } else {
                     $helper->getKeynamesByKeyType($exists);
                 }
             }
         } else {
             if (Keywords::keyExists($offset, "'/'")) {
                 /**
                  *  Handling directory as a list
                  **/
                 $type = array_search('/', $keys);
                 #FB::log($type, 'TYPE');
                 Site::$section = '/' . $offset;
                 $helper->getTasksByKeyword($offset, $type);
                 #FB::info(self::$lists, 'Tasks for Keyword 2');
             } else {
                 #FB::error($offset, 'We don\'t know this');
             }
         }
     } else {
         /**
          *  @todo add javascript handling of location.hash 			
          **/
         #FB::error('@todo location.hash js');
         $helper->getLists();
     }
     if (!isset($helper->lists)) {
         $helper->getLists();
     }
     self::$lists = $helper->lists;
 }
Example #9
0
/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
function smarty_block_keyword($params, $content, &$smarty, &$repeat)
{
    $conditions = array();
    $param_count = count($smarty->_tag_stack);
    if (empty($params['name'])) {
        $params['name'] = "keyword";
    }
    if (!class_exists("Keywords")) {
        uses("keyword");
        $keyword = new Keywords();
        $keyword_controller = new Keyword();
    } else {
        $keyword = new Keywords();
        $keyword_controller = new Keyword();
    }
    $conditions[] = "status=1";
    if (isset($params['typeid'])) {
        $conditions[] = "type='" . intval($params['typeid']) . "'";
    }
    if (isset($params['orderby'])) {
        $orderby = " ORDER BY " . trim($params['orderby']) . " ";
    } else {
        $orderby = " ORDER BY id DESC";
    }
    $keyword->setCondition($conditions);
    $orderby = null;
    $limit = $offset = 0;
    if (isset($params['row'])) {
        $limit = $params['row'];
    }
    if (isset($params['start'])) {
        $offset = $params['start'];
    }
    $keyword->setLimitOffset($offset, $limit);
    $sql = "SELECT id,name,name AS title,name AS fulltitle FROM {$keyword->table_prefix}keywords " . $keyword->getCondition() . "{$orderby}" . $keyword->getLimitOffset();
    $result = $keyword->GetArray($sql);
    $return = null;
    if (!empty($result)) {
        $i_count = count($result);
        for ($i = 0; $i < $i_count; $i++) {
            if (isset($params['titlelen'])) {
                $result[$i]['title'] = mb_substr($result[$i]['title'], 0, $params['titlelen']);
            }
            $url = $keyword->getPermaLink($result[$i]['id']);
            $return .= str_replace(array("[field:title]", "[field:fulltitle]", "[field:id]", "[link:title]"), array($result[$i]['title'], $result[$i]['fulltitle'], $result[$i]['id'], $url), $content);
        }
    }
    return $return;
}
 public function getTasksByKeyword($keyword, $type)
 {
     $tasks = array();
     $keyid = Keywords::getKeyID($keyword, $type);
     #FB::info('Type '.$type.' Keyword '.$keyword.' Keyid '.$keyid, 'getTasksByKeyword');
     $sql = "SELECT `tasks`.`id`, `tasks`.`text`, `tasks`.`raw_string`, `tasks`.`desc`, `tasks`.`date`, `tasks`.`done`,`tasks`.`date_created`,`tasks`.`date_updated`, `tasks`.`priority`,`tasks`.`hidden`,`tasks`.`replyto`\n\t\t\t\tFROM `key_relations` \n\t\t\t\tINNER JOIN `tasks`\n\t\t\t\tON `tasks`.`id` = `key_relations`.`task`\n\t\t\t\tWHERE `key_relations`.`keyword` = " . $keyid . " AND `key_relations`.`user` = " . Site::$user . "\n\t\t\t\tORDER BY `key_relations`.`id` DESC;";
     $result = Site::$db->query($sql);
     #FB::error($result->num_rows, 'SQL');
     if ($result->num_rows > 0) {
         while ($task = $result->fetch_object()) {
             $item = TaskerHelper::getTaskArray($task);
             #FB::info($item, 'ListsHelper');
             $tasks[] = $item;
         }
     }
     $this->lists[$keyid]['list'] = array('id' => $keyid, 'name' => $keyword);
     $this->lists[$keyid]['tasks'] = $tasks;
 }
Example #11
0
 public static function Del($resource_type, $resource_id, $keyword_word)
 {
     if (!($id = Keywords::GetID($keyword_word))) {
         message_die(GENERAL_ERROR, "Keyword not found : {$keyword_word}", 'Keywords::Del fatal error');
     }
     if (Keywords::IsLinked($id, $resource_type, $resource_id)) {
         global $db;
         $sql = "DELETE FROM " . TABLE_RELATIONS . " WHERE parent_type = '{$resource_type}' AND parent_id = '{$resource_id}' AND children_type = 'K' AND children_id = {$id}";
         if (!($result = $db->sql_query($sql))) {
             message_die(SQL_ERROR, "Can't link keyword to specified resource {$resource_type} {$resource_id}", '', __LINE__, __FILE__, $sql);
         }
         //If keyword count = 1, the keyword is not used anymore so we can erase it
         //Just decrements keyword count without any other consideration, so:
         $sql = "UPDATE " . TABLE_KEYWORDS . " SET keyword_count = keyword_count - 1 WHERE keyword_id = {$id}";
         if (!($result = $db->sql_query($sql))) {
             message_die(SQL_ERROR, "Can't decrement keyword count", '', __LINE__, __FILE__, $sql);
         }
     }
 }
Example #12
0
 /**
  * Index
  *
  * Store an entry in the search index.
  * 
  * <code>
  * $this->search_index_m->index(
  *     'blog',
  *     'blog:post',
  *     'blog:posts',
  *     $id,
  *     'blog/'.date('Y/m/', $post->created_on).$post->slug,
  *     $post->title,
  *     $post->intro,
  *     array(
  *         'cp_edit_uri'    => 'admin/blog/edit/'.$id,
  *         'cp_delete_uri'  => 'admin/blog/delete/'.$id,
  *         'keywords'       => $post->keywords, 
  *     )
  * );
  * </code>
  *
  * @param	string	$module		The module that owns this entry 
  * @param	string	$singular	The unique singular language key for this piece of data
  * @param	string	$plural		The unique plural language key that describes many pieces of this data
  * @param	int 	$entry_id	The id for this entry
  * @param	string 	$uri		The relative uri to installation root
  * @param	string 	$title		Title or Name of this entry
  * @param	string 	$description Description of this entry
  * @param	array 	$options	Options such as keywords (array or string - hash of keywords) and cp_edit_url/cp_delete_url
  * @return	array
  */
 public function index($module, $singular, $plural, $entry_id, $uri, $title, $description = null, array $options = array())
 {
     // Drop it so we can create a new index
     $this->drop_index($module, $singular, $entry_id);
     // Hand over keywords without needing to look them up
     if (!empty($options['keywords'])) {
         if (is_array($options['keywords'])) {
             $this->db->set('keywords', implode(',', $options['keywords']));
         } elseif (is_string($options['keywords'])) {
             $this->db->set(array('keywords' => Keywords::get_string($options['keywords']), 'keyword_hash' => $options['keywords']));
         }
     }
     // Store a link to edit this entry
     if (!empty($options['cp_edit_uri'])) {
         $this->db->set('cp_edit_uri', $options['cp_edit_uri']);
     }
     // Store a link to delete this entry
     if (!empty($options['cp_delete_uri'])) {
         $this->db->set('cp_delete_uri', $options['cp_delete_uri']);
     }
     return $this->db->insert('search_index', array('title' => $title, 'description' => strip_tags($description), 'module' => $module, 'entry_key' => $singular, 'entry_plural' => $plural, 'entry_id' => $entry_id, 'uri' => $uri));
 }
Example #13
0
 /**
  * Get data for a page.
  *
  * @param int $id The page id.
  */
 public function details_get($id)
 {
     $this->load->model('page_m');
     // Get the page along with its chunks.
     $page = $this->page_m->get($id);
     if ($page and !empty($page)) {
         // We only require certain columns.
         $fields = array('id', 'slug', 'title', 'uri', 'css', 'js', 'meta_title', 'meta_keywords', 'meta_description', 'rss_enabled', 'comments_enabled', 'is_home', 'status', 'chunks');
         // Just so that we do not redeclare it for every loop.
         $page_keys = array_keys($page);
         foreach ($page_keys as $key) {
             // If the key is not something we are interested in including in our response.
             if (!in_array($key, $fields)) {
                 // unset it.
                 unset($page[$key]);
             }
         }
         $page->meta_keywords = Keywords::get_string($page->meta_keywords);
     }
     // Sent the response out.
     $this->response(array('page' => $page));
 }
Example #14
0
<?php

require_once 'admin.inc.php';
require_once '../include/keywords.class.php';
$curpage = $_GET["p"];
$curpage = isset($curpage) && is_numeric($curpage) ? $curpage : 1;
if ($curpage < 1) {
    $curpage = 1;
}
$searchkey = $_POST["searchkey"];
$keywhere = "";
if ($searchkey != "") {
    $keywhere = "where name like '%{$searchkey}%'";
}
$keywordsdata = new Keywords();
$keywordscount = $keywordsdata->GetKeywordsList($keywhere);
$total = count($keywordscount);
$take = 20;
$skip = ($curpage - 1) * $take;
$totalpage = (int) ($total % $take == 0 ? $total / $take : $total / $take + 1);
$keywordslist = $keywordsdata->TakeKeywordsList($skip, $take, $keywhere);
$action = $_POST["action"];
if ($action == "update") {
    $idarr = $_POST["chk"];
    if (count($idarr) > 0) {
        foreach ($idarr as $id) {
            $name = $_POST["name"];
            $url = $_POST["url"];
            $order = $_POST["order"];
            if (is_numeric($id)) {
                $sql = "update yiqi_keywords set name='" . $name[$id] . "',url='" . $url[$id] . "',displayorder='" . $order[$id] . "' WHERE kid = '{$id}' limit 1";
Example #15
0
 /**
  * Edit blog post
  *
  * @param int $id The ID of the blog post to edit
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/blog');
     $post = $this->blog_m->get($id);
     // They are trying to put this live
     if ($post->status != 'live' and $this->input->post('status') == 'live') {
         role_or_die('blog', 'put_live');
     }
     // If we have keywords before the update, we'll want to remove them from keywords_applied
     $old_keywords_hash = trim($post->keywords) != '' ? $post->keywords : null;
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     // Load up streams
     $this->load->driver('Streams');
     $stream = $this->streams->streams->get_stream('blog', 'blogs');
     $stream_fields = $this->streams_m->get_stream_fields($stream->id, $stream->stream_namespace);
     // Get the validation for our custom blog fields.
     $blog_validation = $this->streams->streams->validation_array($stream->stream_slug, $stream->stream_namespace, 'new');
     $blog_validation = array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:global:title', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:global:slug', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']')));
     // Merge and set our validation rules
     $this->form_validation->set_rules(array_merge($this->validation_rules, $blog_validation));
     $hash = $this->input->post('preview_hash');
     if ($this->input->post('status') == 'draft' and $this->input->post('preview_hash') == '') {
         $hash = $this->_preview_hash();
     } elseif ($this->input->post('status') == 'live') {
         $hash = '';
     }
     if ($this->form_validation->run()) {
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $extra = array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords'), $old_keywords_hash), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'updated_on' => $created_on, 'created' => date('Y-m-d H:i:s', $created_on), 'updated' => date('Y-m-d H:i:s', $created_on), 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : '', 'preview_hash' => $hash);
         if ($this->streams->entries->update_entry($id, $_POST, 'blog', 'blogs', array('updated'), $extra)) {
             $this->session->set_flashdata(array('success' => sprintf(lang('blog:edit_success'), $this->input->post('title'))));
             // Blog article has been updated, may not be anything to do with publishing though
             Events::trigger('post_updated', $id);
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new blog!
                 Events::trigger('post_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', lang('blog:edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/blog') : redirect('admin/blog/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     $post->created_on = $created_on;
     // Set Values
     $values = $this->fields->set_values($stream_fields, $post, 'edit');
     // Run stream field events
     $this->fields->run_field_events($stream_fields, array(), $values);
     $this->template->title($this->module_details['name'], sprintf(lang('blog:edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', array(), true))->append_js('jquery/jquery.tagsinput.js')->append_js('module::blog_form.js')->set('stream_fields', $this->streams->fields->get_stream_fields($stream->stream_slug, $stream->stream_namespace, $values, $post->id))->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
Example #16
0
 /**
  * Process Post
  *
  * Process data that was not part of the 
  * initial streams call.
  *
  * @return 	void
  */
 private function _process_post(&$post)
 {
     $this->load->helper('text');
     // Keywords array
     $keywords = Keywords::get($post['keywords']);
     $formatted_keywords = array();
     $keywords_arr = array();
     foreach ($keywords as $key) {
         $formatted_keywords[] = array('keyword' => $key->name);
         $keywords_arr[] = $key->name;
     }
     $post['keywords'] = $formatted_keywords;
     $post['keywords_arr'] = $keywords_arr;
     // Full URL for convenience.
     $post['url'] = site_url('alert/' . $post['id'] . '/' . date('Y/m/d', $post['created_on']) . '/' . $post['slug']);
     if (file_exists(UPLOAD_PATH . 'alert/' . $post['image']) && is_file(UPLOAD_PATH . 'alert/' . $post['image'])) {
         $image = UPLOAD_PATH . 'alert/' . $post['image'];
     } else {
         $image = UPLOAD_PATH . 'no_image.jpg';
     }
     $this->load->model('files/image_m');
     $post['thumb_detail'] = $this->image_m->resize($image, 200, 150, 'crop');
     // What is the preview? If there is a field called intro,
     // we will use that, otherwise we will cut down the alert post itself.
     $post['preview'] = isset($post['intro']) ? $post['intro'] : $post['body'];
     // Category
     /*if ($post['category_id'] > 0 and isset($this->categories[$post['category_id']]))
     		{
     			$post['category'] = $this->categories[$post['category_id']];
     		}*/
 }
 /**
  * keywords - create a list of keywords from a sting such as a title
  */
 private function keywords($title)
 {
     static $keywordsFilter = null;
     $includePath = dirname(__FILE__) . '/';
     require_once $includePath . 'Keywords.php';
     if (!$keywordsFilter) {
         $keywordsFilter = new Keywords();
     }
     $keywords = $keywordsFilter->keywords($title);
     return $keywords;
 }
Example #18
0
		$card->updated_date = time();
		$card->updated_by = $Utilisateur['user_id'];
		$card->save();
	}

	sajax_init();
	sajax_export("sajax_update_completed");
	sajax_handle_client_request();
*/
//
// Perfoms the search
//
//We need a query
$query = explode(' ', $_GET['q']);
require_once '_includes/IceDeck/Keywords.php';
if (count($cards_id = Keywords::GetResources('C', $query))) {
    foreach ($cards_id as $card_id) {
        $Cards[] = new Card($card_id);
    }
}
//
// HTML output
//
//$value = '<td>'.$i.'</td><td><a href="index.php?guisx=show&pseudo>'.$rows['pseudo'].'</td><td>'.$rows['date_creation'].'</td><td>'.$n_niveau[$rows['niveau']].'</td></a>';
//Header
$smarty->assign('PAGE_TITLE', "Search results - " . $_GET['q']);
$smarty->assign('PAGE_CSS', 'Themes/' . THEME . '/search.css');
//$smarty->assign('SAJAX_JAVASCRIPT_CODE', sajax_get_javascript());
//$smarty->assign('PAGE_JS', array('common.js', 'view.js'));
//$smarty->assign('ACCENT', $card->accent);
//Search variables
Example #19
0
<?php

/**
 *      [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved.
 *      The contents of this file are subject to the License; you may not use this file except in compliance with the License. 
 *
 *      @version $Revision: 2075 $
 */
require "../libraries/common.inc.php";
uses("keyword");
require PHPB2B_ROOT . './libraries/page.class.php';
require "session_cp.inc.php";
include CACHE_COMMON_PATH . "cache_typeoption.php";
$keyword = new Keywords();
$conditions = null;
$tpl_file = "keyword";
$joins = array();
$page = new Pages();
setvar("Status", $_PB_CACHE['common_status']);
if (isset($_GET['do'])) {
    $do = trim($_GET['do']);
    if (!empty($_GET['id'])) {
        $id = intval($_GET['id']);
    }
    if ($do == "edit") {
        if ($id) {
            setvar("item", $keyword->read("*", $id));
        }
        $tpl_file = "keyword.edit";
        template($tpl_file);
        exit;
Example #20
0
    public function getInputJs()
    {
        $types = Keywords::getKeyTypes();
        foreach ($types as $key => $type) {
            $shortcuts[] = <<<JAVASCRIPT
\t\t\t\tcase '{$type[1]}':
\t\t\t\t\tins.addClass('keyword {$type[0]}');
\t\t\t\t\ttype = '{$type[0]}';
\t\t\t\tbreak;
JAVASCRIPT;
            $codes[] = <<<JAVASCRIPT
\t\t\t\t\$(document).data('codes').push('{$type[1]}');
JAVASCRIPT;
        }
        Site::$vars['handleshortcuts'] = implode($shortcuts, ' ');
        Site::$vars['codes'] = implode($codes, ' ');
        return Site::parseFile('static/javascript/tasker.js');
    }
Example #21
0
 /**
  * Process Post
  *
  * Process data that was not part of the 
  * initial streams call.
  *
  * @return 	void
  */
 private function _process_post(&$post)
 {
     $this->load->helper('text');
     // Keywords array
     $keywords = Keywords::get($post['keywords']);
     $formatted_keywords = array();
     $keywords_arr = array();
     foreach ($keywords as $key) {
         $formatted_keywords[] = array('keyword' => $key->name);
         $keywords_arr[] = $key->name;
     }
     $post['keywords'] = $formatted_keywords;
     $post['keywords_arr'] = $keywords_arr;
     // Full URL for convenience.
     $post['url'] = site_url('movie/' . date('Y/m', $post['created_on']) . '/' . $post['slug']);
     // What is the preview? If there is a field called intro,
     // we will use that, otherwise we will cut down the movie post itself.
     $post['preview'] = isset($post['intro']) ? $post['intro'] : $post['body'];
     // Category
     if ($post['category_id'] > 0 and isset($this->categories[$post['category_id']])) {
         $post['category'] = $this->categories[$post['category_id']];
     }
 }
Example #22
0
 /**
  * Edit news post
  *
  * @param int $id The ID of the news post to edit
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/news');
     $post = $this->news_m->get($id);
     // They are trying to put this live
     if ($post->status != 'live' and $this->input->post('status') == 'live') {
         role_or_die('news', 'put_live');
     }
     // If we have keywords before the update, we'll want to remove them from keywords_applied
     $old_keywords_hash = trim($post->keywords) != '' ? $post->keywords : null;
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     // Load up streams
     $this->load->driver('Streams');
     $stream = $this->streams->streams->get_stream('news', 'news');
     $stream_fields = $this->streams_m->get_stream_fields($stream->id, $stream->stream_namespace);
     // Get the validation for our custom news fields.
     $news_validation = $this->streams->streams->validation_array($stream->stream_slug, $stream->stream_namespace, 'new');
     $news_validation = array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:global:title', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:global:slug', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']')));
     // Upload image validation
     if ($_FILES) {
         $allowed = array('.jpg', '.jpeg', '.gif', '.png');
         $upload_key = array_keys($_FILES);
         if (!empty($_FILES[$upload_key[0]]['name']) && $_FILES[$upload_key[0]]['error'] == UPLOAD_ERR_OK) {
             $ext = strtolower(strrchr($_FILES[$upload_key[0]]['name'], '.'));
             if (!in_array($ext, $allowed)) {
                 $this->form_validation->set_error('Invalid image file extension. Allowed extension are .jpg, .jpeg, .png, .gif');
             }
         }
     }
     // Merge and set our validation rules
     $this->form_validation->set_rules(array_merge($this->validation_rules, $news_validation));
     $hash = $this->input->post('preview_hash');
     if ($this->input->post('status') == 'draft' and $this->input->post('preview_hash') == '') {
         $hash = $this->_preview_hash();
     } elseif ($this->input->post('status') == 'live') {
         $hash = '';
     }
     if ($this->form_validation->run()) {
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $extra = array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords'), $old_keywords_hash), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'updated_on' => $created_on, 'created' => date('Y-m-d H:i:s', $created_on), 'updated' => date('Y-m-d H:i:s', $created_on), 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : '', 'preview_hash' => $hash);
         if ($this->streams->entries->update_entry($id, $_POST, 'news', 'news', array('updated'), $extra)) {
             // Upload image
             if ($_FILES) {
                 $upload_key = array_keys($_FILES);
                 if (!empty($_FILES[$upload_key[0]]['name']) && $_FILES[$upload_key[0]]['error'] == UPLOAD_ERR_OK) {
                     $tmp_name = $_FILES[$upload_key[0]]['tmp_name'];
                     $ext = strtolower(strrchr($_FILES[$upload_key[0]]['name'], '.'));
                     $file_name = 'IMG_' . date('Ymd_His') . $ext;
                     if (@move_uploaded_file($tmp_name, $this->_news_base_file_dir . '/' . $file_name)) {
                         @unlink($this->_news_base_file_dir . '/' . $post->image);
                         $this->db->update('news', array('image' => $file_name), array('id' => $id));
                     }
                 }
             }
             $this->session->set_flashdata(array('success' => sprintf(lang('news:edit_success'), $this->input->post('title'))));
             // news article has been updated, may not be anything to do with publishing though
             Events::trigger('post_updated', $id);
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new news!
                 Events::trigger('post_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', lang('news:edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/news') : redirect('admin/news/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     if (file_exists(UPLOAD_PATH . 'news/' . $post->image) && is_file(UPLOAD_PATH . 'news/' . $post->image)) {
         $image = $this->_news_base_file_dir . '/' . $post->image;
         $this->load->model('files/image_m');
         $post->image = $this->_news_base_file_url . '/' . $post->image;
         $post->thumb = $this->image_m->resize($image, 100, 100, 'crop');
     }
     $post->created_on = $created_on;
     // Set Values
     $values = $this->fields->set_values($stream_fields, $post, 'edit');
     // Run stream field events
     $this->fields->run_field_events($stream_fields, array(), $values);
     $this->template->title($this->module_details['name'], sprintf(lang('news:edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', array(), true))->append_js('jquery/jquery.tagsinput.js')->append_js('module::news_form.js')->set('stream_fields', $this->streams->fields->get_stream_fields($stream->stream_slug, $stream->stream_namespace, $values, $post->id))->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
Example #23
0
 /**
  * Tag/Keyword List
  *
  * Create a list of blog keywords/tags
  *
  * Usage:
  * {{ blog:tags limit="10" }}
  *		<span><a href="{{ url }}" title="{{ title }}">{{ title }}</a></span>
  * {{ /blog:tags }}
  *
  * @param array
  * @return array
  */
 public function tags()
 {
     $limit = $this->attribute('limit', null);
     $this->load->library(array('keywords/keywords'));
     $posts = $this->db->select('keywords')->get('news')->result();
     $buffer = array();
     // stores already added keywords
     $tags = array();
     foreach ($posts as $p) {
         $kw = Keywords::get_array($p->keywords);
         foreach ($kw as $k) {
             $k = trim(strtolower($k));
             if (!in_array($k, $buffer)) {
                 $buffer[] = $k;
                 $tags[] = array('title' => ucfirst($k), 'url' => site_url('news/tagged/' . $k));
             }
         }
     }
     if (count($tags) > $limit) {
         return array_slice($tags, 0, $limit);
     }
     return $tags;
 }
Example #24
0
 private function searchByType($text, $Excluded = [], $type = 'Movies')
 {
     $query = Keywords::query()->where('MATCH(keywords) AGAINST("' . $this->keywords_encode($text) . '")')->andWhere('Keywords.keywordable_type = "' . $type . '"')->leftJoin($type, $type . '.id = Keywords.keywordable_id AND Keywords.keywordable_type = "' . $type . '"')->columns([$type . '.*', 'Keywords.*'])->limit(10);
     if ($Excluded != []) {
         $query = $query->notInWhere($type . '.id', $Excluded);
     }
     $rows = $query->execute();
     $result = [];
     foreach ($rows as $row) {
         $result[] = $row->{strtolower($type)};
     }
     return $result;
 }
Example #25
0
<?php

require_once '_includes/cloud.php';
//Ensures data integrity
Keywords::Clean();
Keywords::SyncCount();
//Color cloud
$table = TABLE_CARDS;
$field = 'card_accent';
$qt = 'count(card_id)';
$nullString = 'incolor';
$colorCloud = new Cloud($table, $field, $qt);
$colorCloud->nullString = $nullString;
$colorCloud->Compute();
//Regular cloud
//Color cloud
$table = TABLE_KEYWORDS;
$field = 'keyword_word';
$qt = 'keyword_count';
$nullString = '(blank keyword)';
$Cloud = new Cloud($table, $field, $qt);
$Cloud->nullString = $nullString;
$Cloud->Compute();
//
// HTML output
//
//Header
$smarty->assign('PAGE_TITLE', "Cloud");
$smarty->assign('PAGE_CSS', 'Themes/' . THEME . '/cloud.css');
//Cloud variables
$smarty->assign('KeywordsCloud', $Cloud->cloud);
Example #26
0
 public function HasKeyword($keyword)
 {
     Keywords::Has('C', $this->id, $keyword);
 }
Example #27
0
 /**
  * Edit blog post
  *
  * @access public
  * @param int $id the ID of the blog post to edit
  * @return void
  */
 public function edit($id = 0)
 {
     $id or redirect('admin/blog');
     $post = $this->blog_m->get($id);
     $post->keywords = Keywords::get_string($post->keywords);
     // If we have a useful date, use it
     if ($this->input->post('created_on')) {
         $created_on = strtotime(sprintf('%s %s:%s', $this->input->post('created_on'), $this->input->post('created_on_hour'), $this->input->post('created_on_minute')));
     } else {
         $created_on = $post->created_on;
     }
     $this->form_validation->set_rules(array_merge($this->validation_rules, array('title' => array('field' => 'title', 'label' => 'lang:blog_title_label', 'rules' => 'trim|htmlspecialchars|required|max_length[100]|callback__check_title[' . $id . ']'), 'slug' => array('field' => 'slug', 'label' => 'lang:blog_slug_label', 'rules' => 'trim|required|alpha_dot_dash|max_length[100]|callback__check_slug[' . $id . ']'))));
     if ($this->form_validation->run()) {
         // They are trying to put this live
         if ($post->status != 'live' and $this->input->post('status') == 'live') {
             role_or_die('blog', 'put_live');
         }
         $author_id = empty($post->display_name) ? $this->current_user->id : $post->author_id;
         $result = $this->blog_m->update($id, array('title' => $this->input->post('title'), 'slug' => $this->input->post('slug'), 'category_id' => $this->input->post('category_id'), 'keywords' => Keywords::process($this->input->post('keywords')), 'intro' => $this->input->post('intro'), 'body' => $this->input->post('body'), 'status' => $this->input->post('status'), 'created_on' => $created_on, 'comments_enabled' => $this->input->post('comments_enabled'), 'author_id' => $author_id, 'type' => $this->input->post('type'), 'parsed' => $this->input->post('type') == 'markdown' ? parse_markdown($this->input->post('body')) : ''));
         if ($result) {
             $this->session->set_flashdata(array('success' => sprintf(lang('blog_edit_success'), $this->input->post('title'))));
             // They are trying to put this live
             if ($post->status != 'live' and $this->input->post('status') == 'live') {
                 // Fire an event, we're posting a new blog!
                 Events::trigger('blog_article_published', $id);
             }
         } else {
             $this->session->set_flashdata('error', $this->lang->line('blog_edit_error'));
         }
         // Redirect back to the form or main page
         $this->input->post('btnAction') == 'save_exit' ? redirect('admin/blog') : redirect('admin/blog/edit/' . $id);
     }
     // Go through all the known fields and get the post values
     foreach ($this->validation_rules as $key => $field) {
         if (isset($_POST[$field['field']])) {
             $post->{$field}['field'] = set_value($field['field']);
         }
     }
     $post->created_on = $created_on;
     $this->template->title($this->module_details['name'], sprintf(lang('blog_edit_title'), $post->title))->append_metadata($this->load->view('fragments/wysiwyg', $this->data, TRUE))->append_js('jquery/jquery.tagsinput.js')->append_js('module::blog_form.js')->append_css('jquery/jquery.tagsinput.css')->set('post', $post)->build('admin/form');
 }
Example #28
0
    /**
     * Page method
     *
     * @param array $url_segments The URL segments.
     */
    public function _page($url_segments)
    {
        // Get our chunks field type if this is an
        // upgraded site.
        if ($this->db->table_exists('page_chunks')) {
            $this->type->load_types_from_folder(APPPATH . 'modules/pages/field_types/', 'pages_module');
        }
        // If we are on the development environment,
        // we should get rid of the cache. That ways we can just
        // make updates to the page type files and see the
        // results immediately.
        if (ENVIRONMENT == PYRO_DEVELOPMENT) {
            $this->pyrocache->delete_all('page_m');
        }
        // GET THE PAGE ALREADY. In the event of this being the home page $url_segments will be null
        $page = $this->page_m->get_by_uri($url_segments, true);
        // Setting this so others may use it.
        $this->template->set('page', $page);
        // If page is missing or not live (and the user does not have permission) show 404
        if (!$page or $page->status == 'draft' and !$this->permission_m->has_role(array('put_live', 'edit_live'))) {
            // Load the '404' page. If the actual 404 page is missing (oh the irony) bitch and quit to prevent an infinite loop.
            if (!($page = $this->pyrocache->model('page_m', 'get_by_uri', array('404')))) {
                show_error('The page you are trying to view does not exist and it also appears as if the 404 page has been deleted.');
            }
        }
        // the home page won't have a base uri
        isset($page->base_uri) or $page->base_uri = $url_segments;
        // If this is a homepage, do not show the slug in the URL
        if ($page->is_home and $url_segments) {
            redirect('', 'location', 301);
        }
        // If the page is missing, set the 404 status header
        if ($page->slug == '404') {
            $this->output->set_status_header(404);
        } elseif ($page->restricted_to) {
            $page->restricted_to = (array) explode(',', $page->restricted_to);
            // Are they logged in and an admin or a member of the correct group?
            if (!$this->current_user or isset($this->current_user->group) and $this->current_user->group != 'admin' and !in_array($this->current_user->group_id, $page->restricted_to)) {
                // send them to login but bring them back when they're done
                redirect('users/login/' . (empty($url_segments) ? '' : implode('/', $url_segments)));
            }
        }
        // We want to use the valid uri from here on. Don't worry about segments passed by Streams or
        // similar. Also we don't worry about breadcrumbs for 404
        if ($url_segments = explode('/', $page->base_uri) and count($url_segments) > 1) {
            // we dont care about the last one
            array_pop($url_segments);
            // This array of parents in the cache?
            if (!($parents = $this->pyrocache->get('page_m/' . md5(implode('/', $url_segments))))) {
                $parents = $breadcrumb_segments = array();
                foreach ($url_segments as $segment) {
                    $breadcrumb_segments[] = $segment;
                    $parents[] = $this->pyrocache->model('page_m', 'get_by_uri', array($breadcrumb_segments, true, true));
                }
                // Cache for next time
                $this->pyrocache->write($parents, 'page_m/' . md5(implode('/', $url_segments)));
            }
            foreach ($parents as $parent_page) {
                $this->template->set_breadcrumb($parent_page->title, $parent_page->uri);
            }
        }
        // If this page has an RSS feed, show it
        if ($page->rss_enabled) {
            $this->template->append_metadata('<link rel="alternate" type="application/rss+xml" title="' . $page->meta_title . '" href="' . site_url(uri_string() . '.rss') . '" />');
        }
        // Set pages layout files in your theme folder
        if ($this->template->layout_exists($page->uri . '.html')) {
            $this->template->set_layout($page->uri . '.html');
        }
        // If a Page Type has a Theme Layout that exists, use it
        if (!empty($page->layout->theme_layout) and $this->template->layout_exists($page->layout->theme_layout) and ($this->template->layout_is('default.html') or $page->layout->theme_layout !== 'default.html')) {
            $this->template->set_layout($page->layout->theme_layout);
        }
        // ---------------------------------
        // Metadata
        // ---------------------------------
        // First we need to figure out our metadata. If we have meta for our page,
        // that overrides the meta from the page layout.
        $meta_title = $page->meta_title ? $page->meta_title : $page->layout->meta_title;
        $meta_description = $page->meta_description ? $page->meta_description : $page->layout->meta_description;
        $meta_keywords = '';
        if ($page->meta_keywords or $page->layout->meta_keywords) {
            $meta_keywords = $page->meta_keywords ? Keywords::get_string($page->meta_keywords) : Keywords::get_string($page->layout->meta_keywords);
        }
        $meta_robots = $page->meta_robots_no_index ? 'noindex' : 'index';
        $meta_robots .= $page->meta_robots_no_follow ? ',nofollow' : ',follow';
        // They will be parsed later, when they are set for the template library.
        // Not got a meta title? Use slogan for homepage or the normal page title for other pages
        if (!$meta_title) {
            $meta_title = $page->is_home ? $this->settings->site_slogan : $page->title;
        }
        // Set the title, keywords, description, and breadcrumbs.
        $this->template->title($this->parser->parse_string($meta_title, $page, true))->set_metadata('keywords', $this->parser->parse_string($meta_keywords, $page, true))->set_metadata('robots', $meta_robots)->set_metadata('description', $this->parser->parse_string($meta_description, $page, true))->set_breadcrumb($page->title);
        // Parse the CSS so we can use tags like {{ asset:inline_css }}
        // #foo {color: red} {{ /asset:inline_css }}
        // to output css via the {{ asset:render_inline_css }} tag. This is most useful for JS
        $css = $this->parser->parse_string($page->layout->css . $page->css, $this, true);
        // there may not be any css (for sure after parsing Lex tags)
        if ($css) {
            $this->template->append_metadata('
				<style type="text/css">
					' . $css . '
				</style>', 'late_header');
        }
        $js = $this->parser->parse_string($page->layout->js . $page->js, $this, true);
        // Add our page and page layout JS
        if ($js) {
            $this->template->append_metadata('
				<script type="text/javascript">
					' . $js . '
				</script>');
        }
        // If comments are enabled, go fetch them all
        if (Settings::get('enable_comments')) {
            // Load Comments so we can work out what to do with them
            $this->load->library('comments/comments', array('entry_id' => $page->id, 'entry_title' => $page->title, 'module' => 'pages', 'singular' => 'pages:page', 'plural' => 'pages:pages'));
        }
        // Get our stream.
        $stream = $this->streams_m->get_stream($page->layout->stream_id);
        // We are going to pre-build this data so we have the data
        // available to the template plugin (since we are pre-parsing our views).
        $template = $this->template->build_template_data();
        // Parse our view file. The view file is nothing
        // more than an echo of $page->layout->body and the
        // comments after it (if the page has comments).
        $html = $this->template->load_view('pages/page', array('page' => $page), false);
        $view = $this->parser->parse_string($html, $page, true, false, array('stream' => $stream->stream_slug, 'namespace' => $stream->stream_namespace, 'id_name' => 'entry_id'));
        if ($page->slug == '404') {
            log_message('error', 'Page Missing: ' . $this->uri->uri_string());
            // things behave a little differently when called by MX from MY_Exceptions' show_404()
            exit($this->template->build($view, array('page' => $page), false, false, true, $template));
        }
        $this->template->build($view, array('page' => $page), false, false, true, $template);
    }
Example #29
0
 /**
  * Edit an existing page
  *
  * @param int $id The id of the page.
  */
 public function edit($id = 0)
 {
     // We are lost without an id. Redirect to the pages index.
     $id or redirect('admin/pages');
     // The user needs to be able to edit pages.
     role_or_die('pages', 'edit_live');
     // Retrieve the page data along with its chunk data as an array.
     $page = $this->page_m->get($id);
     // If there's a keywords hash
     if ($page->meta_keywords != '') {
         // Get comma-separated meta_keywords based on keywords hash
         $this->load->model('keywords/keyword_m');
         $old_keywords_hash = $page->meta_keywords;
         $page->meta_keywords = Keywords::get_string($page->meta_keywords);
     }
     // Turn the CSV list back to an array
     $page->restricted_to = explode(',', $page->restricted_to);
     // Got page?
     if (!$page or empty($page)) {
         // Maybe you would like to create one?
         $this->session->set_flashdata('error', lang('pages_page_not_found_error'));
         redirect('admin/pages/create');
     }
     // did they even submit?
     if ($input = $this->input->post()) {
         // do they have permission to proceed?
         if ($input['status'] == 'live') {
             role_or_die('pages', 'put_live');
         }
         // were there keywords before this update?
         if (isset($old_keywords_hash)) {
             $input['old_keywords_hash'] = $old_keywords_hash;
         }
         // validate and insert
         if ($this->page_m->edit($id, $input)) {
             $this->session->set_flashdata('success', sprintf(lang('pages_edit_success'), $input['title']));
             Events::trigger('page_updated', $id);
             $this->pyrocache->delete_all('page_m');
             $this->pyrocache->delete_all('navigation_m');
             // Mission accomplished!
             $input['btnAction'] == 'save_exit' ? redirect('admin/pages') : redirect('admin/pages/edit/' . $id);
         } else {
             // validation failed, we must repopulate the chunks form
             $chunk_slugs = $this->input->post('chunk_slug') ? array_values($this->input->post('chunk_slug')) : array();
             $chunk_classes = $this->input->post('chunk_class') ? array_values($this->input->post('chunk_class')) : array();
             $chunk_bodies = $this->input->post('chunk_body') ? array_values($this->input->post('chunk_body')) : array();
             $chunk_types = $this->input->post('chunk_type') ? array_values($this->input->post('chunk_type')) : array();
             $page->chunks = array();
             $chunk_bodies_count = count($input['chunk_body']);
             for ($i = 0; $i < $chunk_bodies_count; $i++) {
                 $page->chunks[] = array('id' => $i, 'slug' => !empty($chunk_slugs[$i]) ? $chunk_slugs[$i] : '', 'class' => !empty($chunk_classes[$i]) ? $chunk_classes[$i] : '', 'type' => !empty($chunk_types[$i]) ? $chunk_types[$i] : '', 'body' => !empty($chunk_bodies[$i]) ? $chunk_bodies[$i] : '');
             }
         }
     }
     // Loop through each validation rule
     foreach ($this->page_m->fields() as $field) {
         // Nothing to do for these two fields.
         if (in_array($field, array('navigation_group_id', 'chunk_body[]'))) {
             continue;
         }
         // Translate the data of restricted_to to something we can use in the form.
         if ($field === 'restricted_to[]') {
             $page->restricted_to = set_value($field, $page->restricted_to);
             $page->restricted_to[0] = $page->restricted_to[0] == '' ? '0' : $page->restricted_to[0];
             continue;
         }
         // Set all the other fields
         $page->{$field} = set_value($field, $page->{$field});
     }
     // If this page has a parent.
     if ($page->parent_id > 0) {
         // Get only the details for the parent, no chunks.
         $parent_page = $this->page_m->get($page->parent_id, false);
     } else {
         $parent_page = false;
     }
     $this->_form_data();
     $this->template->title($this->module_details['name'], sprintf(lang('pages:edit_title'), $page->title))->append_metadata($this->load->view('fragments/wysiwyg', array(), true))->append_css('module::page-edit.css')->set('page', $page)->set('parent_page', $parent_page)->build('admin/form');
 }
Example #30
0
 public function tagged($tag = '')
 {
     $tag or redirect('blog');
     // Count total blog posts and work out how many pages exist
     $pagination = create_pagination('blog/tagged/' . $tag, $this->blog_m->count_tagged_by($tag, array('status' => 'live')), NULL, 4);
     // Get the current page of blog posts
     $blog = $this->blog_m->limit($pagination['limit'])->get_tagged_by($tag, array('status' => 'live'));
     foreach ($blog as &$post) {
         $post->keywords = Keywords::get_links($post->keywords, 'blog/tagged');
     }
     // Set meta description based on post titles
     $meta = $this->_posts_metadata($blog);
     $name = str_replace('-', ' ', $tag);
     // Build the page
     $this->template->title($this->module_details['name'], lang('blog_tagged_label') . ': ' . $name)->set_metadata('description', lang('blog_tagged_label') . ': ' . $name . '. ' . $meta['description'])->set_metadata('keywords', $name)->set_breadcrumb(lang('blog_blog_title'), 'blog')->set_breadcrumb(lang('blog_tagged_label') . ': ' . $name)->set('blog', $blog)->set('tag', $tag)->set('pagination', $pagination)->build('tagged', $this->data);
 }