Example #1
0
 public function addPage($at = null, $fileKey, $oldName)
 {
     $this->_pageKeys[] = $fileKey;
     $page = new Page($this->_DBI);
     $page->setKey($fileKey);
     $page->set('oldFileName', $oldName);
     $page->set('scriptKey', $this->_script->getKey());
     $page->create();
 }
Example #2
0
	public function indexOp(){
		//die("");
		Language::read('home_index_index');
		Tpl::output('index_sign','index');

		//抢购专区
		Language::read('member_groupbuy');
        $model_groupbuy = Model('groupbuy');
        $group_list = $model_groupbuy->getGroupbuyCommendedList(4);
		Tpl::output('group_list', $group_list);
        //友情链接
		$model_link = Model('link');
		$link_list = $model_link->getLinkList($condition,$page);
		/**
		 * 整理图片链接
		 */
		if (is_array($link_list)){
			foreach ($link_list as $k => $v){
				if (!empty($v['link_pic'])){
					$link_list[$k]['link_pic'] = UPLOAD_SITE_URL.'/'.ATTACH_PATH.'/common/'.DS.$v['link_pic'];
				}
			}
		}
		Tpl::output('$link_list',$link_list);
		//限时折扣
        $model_xianshi_goods = Model('p_xianshi_goods');
        $xianshi_item = $model_xianshi_goods->getXianshiGoodsCommendList(4);
		Tpl::output('xianshi_item', $xianshi_item);

		//板块信息
		$model_web_config = Model('web_config');
		$web_html = $model_web_config->getWebHtml('index');
		Tpl::output('web_html',$web_html);

		/*特惠商家*/
		$condition = array();
		$order = 'store_sort asc';
		$model_store = Model('store');
		$store_list = $model_store->where($condition)->order($order)->page(5)->select();
		Tpl::output('store_list', $store_list);

		//-S------------------------------------------------
		//最新评论+热闹活动
		$model_evaluate_goods = Model('evaluate_goods');
		$where = array();
		$tmp = $model_evaluate_goods->getEvaluateGoodsList($where, 2);
		Tpl::output('evaluate_list', $tmp);

		$model_activity_detail = Model('activity_detail');
		$awhere = array();
		$awhere['order'] = " activity_detail_sort desc,activity_detail_id desc ";
		$p = new Page();
		$p->set('each_num', 2);
		$tmp = $model_activity_detail->getGoodsList($awhere, $p);
		Tpl::output('activity_detail_list', $tmp);
		//-E------------------------------------------------

		Model('seo')->type('index')->show();
		Tpl::showpage('index');
	}
Example #3
0
 /**
  * 初期データを読み込む
  * 
  * @param string $dbConfigKeyName
  * @param array $dbConfig
  * @param string $pattern
  * @param string $theme
  * @param string $plugin
  * @return boolean 
  */
 public function loadDefaultDataPattern($dbConfigKeyName, $dbConfig, $pattern, $theme = 'core', $plugin = 'core', $excludes = array())
 {
     $db = $this->_getDataSource($dbConfigKeyName, $dbConfig);
     $path = BcUtil::getDefaultDataPath($plugin, $theme, $pattern);
     if (!$path) {
         return false;
     }
     $corePath = BcUtil::getDefaultDataPath($plugin, 'core', 'default');
     $targetTables = array();
     if ($corePath) {
         $Folder = new Folder($corePath);
         $files = $Folder->read(true, true);
         $targetTables = $files[1];
     }
     $Folder = new Folder($path);
     $files = $Folder->read(true, true, true);
     if (!$targetTables) {
         $targetTables = $files[1];
     }
     $result = true;
     foreach ($targetTables as $targetTable) {
         $targetTable = basename($targetTable, '.csv');
         $loaded = false;
         if (!in_array($targetTable, $excludes)) {
             // 初期データ投入
             foreach ($files[1] as $file) {
                 if (!preg_match('/\\.csv$/', $file)) {
                     continue;
                 }
                 $table = basename($file, '.csv');
                 if ($table == $targetTable) {
                     if (!$db->loadCsv(array('path' => $file, 'encoding' => 'SJIS'))) {
                         $this->log($file . ' の読み込みに失敗。');
                         $result = false;
                     } else {
                         $loaded = true;
                         break;
                     }
                 }
             }
             // 存在しなかった場合は、コアのファイルを読み込む
             if (!$loaded && $corePath) {
                 if (!$db->loadCsv(array('path' => $corePath . DS . $targetTable . '.csv', 'encoding' => 'SJIS'))) {
                     $this->log($corePath . DS . $targetTable . ' の読み込みに失敗。');
                     $result = false;
                 }
             }
         }
     }
     App::uses('Page', 'Model');
     App::uses('PageCategory', 'Model');
     $Page = new Page();
     $Page->PageCategory = new PageCategory();
     // モバイルのID書き換え(ClearDB対策)
     $agents = array(1 => 'mobile', 2 => 'smartphone');
     foreach ($agents as $key => $agent) {
         $agentId = $Page->PageCategory->getAgentId($agent);
         if ($agentId != $key) {
             $pages = $Page->find('all', array('conditions' => array('Page.page_category_id' => $key), 'recursive' => -1));
             foreach ($pages as $page) {
                 $page['Page']['page_category_id'] = $agentId;
                 $Page->fileSave = false;
                 $Page->contentSaving = false;
                 $Page->set($page);
                 if (!$Page->save()) {
                     $result = false;
                 }
             }
         }
     }
     return $result;
 }
 /**
  * Handler for the InputfieldPageTableAdd ajax action
  * 
  * @param Page $page
  * @param Field $field
  * @param Page $item
  * @return bool
  * 
  */
 protected function addItem(Page $page, Field $field, Page $item)
 {
     // add an item and save the field
     if (!$item->id || $item->createdUser->id != $this->wire('user')->id) {
         return false;
     }
     $value = $page->getUnformatted($field->name);
     if ($value instanceof PageArray && !$value->has($item)) {
         $of = $page->of();
         $page->of(false);
         $value->add($item);
         $page->set($field->name, $value);
         $page->save($field->name);
         $this->notes = $this->_('Added item') . ' - ' . $item->name;
         $page->of($of);
         return true;
     }
     return false;
 }
Example #5
0
    }
    return $curated;
}
if (!defined('COVER')) {
    $benchmark_start = microtime_float();
    // get xml
    $curated = curated_xml('all');
    // count number of items
    $ctotal = count($curated);
    // count number of pages needed
    $cnum_pages = ceil($ctotal / CURATED_PER_PAGE);
    // create and write the other pages
    for ($i = 0; $i <= $cnum_pages; $i++) {
        $page = new Page('Exhibition Archives', 'Exhibition');
        $page->subtemplate('template.curated.archive.html');
        $page->set('curated_nav', curated_nav($cnum_pages, $i + 1));
        $page->set('exhibition', get_curated_three($curated, CURATED_PER_PAGE * $i, CURATED_PER_PAGE));
        //$pagename = sprintf("curated_page_%d.html", $i+1);
        if ($i == 0) {
            $pagename = sprintf("index.html");
        } else {
            $pagename = sprintf("curated_page_%d.html", $cnum_pages - $i);
        }
        writeFile("exhibition/" . $pagename, $page->out());
    }
    $benchmark_end = microtime_float();
    $execution_time = round($benchmark_end - $benchmark_start, 4);
    if (!defined('SUBMIT')) {
    }
}
function curated_nav($num, $current)
Example #6
0
 /**
  * Auto-assign a page name to this page
  * 
  * Typically this would be used only if page had no name or if it had a temporary untitled name.
  * 
  * Page will be populated with the name given. This method will not populate names to pages that
  * already have a name, unless the name is "untitled"
  * 
  * @param Page $page
  * @param array $options 
  * 	- format: Optionally specify the format to use, or leave blank to auto-determine.
  * @return string If a name was generated it is returned. If no name was generated blank is returned. 
  * 
  */
 public function ___setupPageName(Page $page, array $options = array())
 {
     $defaults = array('format' => '');
     $options = array_merge($defaults, $options);
     $format = $options['format'];
     if (strlen($page->name)) {
         // make sure page starts with "untitled" or "untitled-"
         if ($page->name != $this->untitledPageName && strpos($page->name, "{$this->untitledPageName}-") !== 0) {
             // page already has a name and it's not a temporary/untitled one
             // so we do nothing
             return '';
         }
         // page starts with our untitled name, but is it in the exact format we use?
         if ($page->name != $this->untitledPageName) {
             $parts = explode('-', $page->name);
             array_shift($parts);
             // shift off 'untitled';
             $parts = implode('', $parts);
             // put remaining back together
             // if we were left with something other than digits,
             // this is not an auto-generated name, so leave as-is
             if (!ctype_digit($parts)) {
                 return '';
             }
         }
     }
     if (!strlen($format)) {
         $format = $page->parent()->template->childNameFormat;
     }
     if (!strlen($format)) {
         if (strlen($page->title)) {
             // default format is title
             $format = 'title';
         } else {
             // if page has no title, default format is date
             $format = 'Y-m-d H:i:s';
         }
     }
     $pageName = '';
     if (strlen($format)) {
         // @todo add option to auto-gen name from any page property/field
         if ($format == 'title') {
             if (strlen($page->title)) {
                 $pageName = $page->title;
             } else {
                 $pageName = $this->untitledPageName;
             }
         } else {
             if (!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) {
                 // it is a date format
                 $pageName = date($format);
             } else {
                 // predefined format
                 $pageName = $format;
             }
         }
     } else {
         if (strlen($page->title)) {
             $pageName = $page->title;
         } else {
             // no name will be assigned
         }
     }
     if ($pageName == $this->untitledPageName && strpos($page->name, $this->untitledPageName) === 0) {
         // page already has untitled name, and there's no need to re-assign the untitled name
         return '';
     }
     $name = '';
     if (strlen($pageName)) {
         // make the name unique
         $pageName = $this->wire('sanitizer')->pageName($pageName, Sanitizer::translate);
         $numChildren = $page->parent->numChildren();
         $n = 0;
         do {
             $name = $pageName;
             if ($n > 0) {
                 $nStr = "-" . ($numChildren + $n);
                 if (strlen($name) + strlen($nStr) > self::nameMaxLength) {
                     $name = substr($name, 0, self::nameMaxLength - strlen($nStr));
                 }
                 $name .= $nStr;
             }
             $n++;
         } while ($n < 100 && $this->count("parent={$page->parent}, name={$name}, include=all"));
         $page->name = $name;
         $page->set('_hasAutogenName', true);
         // for savePageQuery, provides adjustName behavior for new pages
     }
     return $name;
 }
Example #7
0
 static function register($id, $key = false, $value = "")
 {
     // stop if variable already available
     //if(array_key_exists("pages", $GLOBALS['db_schema']) && in_array($key, $GLOBALS['db_schema']['pages'])) return;
     $page = new Page();
     $columns = $GLOBALS['db_schema']['pages'];
     $dbh = $page->getdbh();
     // check if the pages table exists
     $sql = "SELECT name FROM sqlite_master WHERE type='table' and name='pages'";
     $results = $dbh->prepare($sql);
     $results->execute();
     $table = $results->fetch(PDO::FETCH_ASSOC);
     // then check if the table exists
     if (!is_array($table)) {
         $keys = implode(", ", $columns);
         // FIX: The id needs to be setup as autoincrement
         $keys = str_replace("id,", "id INTEGER PRIMARY KEY ASC,", $keys);
         $page->create_table("pages", $keys);
         //$page->create_table("pages", "id INTEGER PRIMARY KEY ASC, title, content, path, date, tags, template");
     }
     // add the column if necessary
     if (array_key_exists("pages", $GLOBALS['db_schema']) && is_array($columns) && !in_array($key, $columns)) {
         $sql = "ALTER TABLE pages ADD COLUMN " . $key;
         $results = $dbh->prepare($sql);
         if ($results) {
             $results->execute();
         }
         // there's a case where the column may already exist, in which case this will be false...
         array_push($columns, $key);
     }
     // get existing page (again?)
     $sql = "SELECT * FROM 'pages' WHERE id='{$id}'";
     $results = $dbh->prepare($sql);
     if ($results) {
         $results->execute();
         $pages = $results->fetch(PDO::FETCH_ASSOC);
     } else {
         $pages = false;
     }
     // just create the key
     if (!$pages) {
         $newpage = new Page();
         $newpage->set('id', "{$id}");
         if ($key) {
             $newpage->set("{$key}", "{$value}");
         }
         $newpage->create();
     } else {
         if ($key) {
             $mypage = new Page($id);
             $existing = $mypage->get("{$key}");
             // allow empty strings to be returned
             if (is_null($existing)) {
                 $mypage->set("{$key}", "{$value}");
                 $mypage->update();
             }
         }
     }
 }
Example #8
0
}
/**
 * pages テーブル更新
 *
 * 作成者のデータを追加
 */
$db =& ConnectionManager::getDataSource('plugin');
$db->cacheQueries = false;
App::import('Model', 'Plugin');
$Page = new Page();
$pages = $Page->find('all');
$result = true;
if ($pages) {
    foreach ($pages as $page) {
        $page['Page']['author_id'] = 1;
        $Page->set($page);
        if (!$Page->save()) {
            $result = false;
        }
    }
}
if ($result) {
    $this->setMessage('pages テーブルの更新に成功しました。');
} else {
    $this->setMessage('pages テーブルの更新に失敗しました。', true);
}
/**
 * site_configs 更新
 */
App::import('Model', 'SiteConfig');
App::import('Model', 'Mail.MailConfig');
Example #9
0
<?php

require_once '../config.php';
DEFINE('COVER', true);
//require_once('updates.php');
//if (!defined('SUBMIT')) {
//    require_once('happenings.php');
//    require_once('courses.php');
//}
require_once 'exhibition.php';
$benchmark_start = microtime_float();
$page = new Page('', 'Cover');
$page->subtemplate('template.cover.html');
//$page->set('updates', get_updates(24));
//$page->set('happenings', get_happenings(5));
//$page->set('courses', get_courses_short(5));
$page->set('exhibition', get_curated_short());
writeFile("index.php", $page->out());
$benchmark_end = microtime_float();
$execution_time = round($benchmark_end - $benchmark_start, 4);
if (!defined('SUBMIT')) {
    echo <<<EOC
<h2>Index.php Generation Successful</h2> <p>Generator took {$execution_time} seconds to execute</p>
EOC;
}
Example #10
0
 /**
  * Install a dedicated page for this Process module and assign it this Process
  * 
  * To be called by Process module's ___install() method. 
  *
  * @param string $name Desired name of page, or omit (or blank) to use module name
  * @param Page|string|int|null Parent for the page, with one of the following:
  * 	- name of parent, relative to admin root, i.e. "setup"
  * 	- Page object of parent
  * 	- path to parent
  * 	- parent ID
  * 	- Or omit and admin root is assumed
  * @param string $title Omit or blank to pull title from module information
  * @param string|Template Template to use for page (omit to assume 'admin')
  * @param array $extras Any extra properties to assign (like status)
  * @return Page Returns the page that was created
  * @throws WireException if page can't be created
  *
  */
 protected function ___installPage($name = '', $parent = null, $title = '', $template = 'admin', $extras = array())
 {
     $info = $this->wire('modules')->getModuleInfoVerbose($this);
     $name = $this->wire('sanitizer')->pageName($name);
     if (!strlen($name)) {
         $name = strtolower(preg_replace('/([A-Z])/', '-$1', str_replace('Process', '', $this->className())));
     }
     $adminPage = $this->wire('pages')->get($this->wire('config')->adminRootPageID);
     if ($parent instanceof Page) {
         $parent = $parent;
     } else {
         if (ctype_digit("{$parent}")) {
             $parent = $this->wire('pages')->get((int) $parent);
         } else {
             if (strpos($parent, '/') !== false) {
                 $parent = $this->wire('pages')->get($parent);
             } else {
                 if ($parent) {
                     $parent = $adminPage->child("include=all, name=" . $this->wire('sanitizer')->pageName($parent));
                 }
             }
         }
     }
     if (!$parent || !$parent->id) {
         $parent = $adminPage;
     }
     // default
     $page = $parent->child("include=all, name={$name}");
     // does it already exist?
     if ($page->id && $page->process == $this) {
         return $page;
     }
     // return existing copy
     $page = new Page();
     $page->template = $template ? $template : 'admin';
     $page->name = $name;
     $page->parent = $parent;
     $page->process = $this;
     $page->title = $title ? $title : $info['title'];
     foreach ($extras as $key => $value) {
         $page->set($key, $value);
     }
     $this->wire('pages')->save($page, array('adjustName' => true));
     if (!$page->id) {
         throw new WireException("Unable to create page: {$parent->path}{$name}");
     }
     $this->message(sprintf($this->_('Created Page: %s'), $page->path));
     return $page;
 }
Example #11
0
 function save($params = array())
 {
     // define/filter the data set
     $fields = array("id", "title", "content", "tags", "template");
     $data = array_fill_keys($fields, "");
     $data = array_merge($data, $params);
     // filter data...
     $page = new Page($data['id']);
     // trigger event
     Event::trigger('admin:save', $data);
     foreach ($data as $k => $v) {
         $page->set($k, $v);
     }
     if (array_key_exists("id", $params)) {
         // Update existing page
         $page->update();
     } else {
         // Create new page
         //$page->set('path', 		$data['path']);
         $page->create();
     }
     // Generate sitemap
     $sitemap = new Sitemap();
 }
 public static function getPageTemplate($url)
 {
     if (count(Request::getAllRequest())) {
         switch (Request::post("type")) {
             case 'user':
                 $user = new User();
                 $user->set("email_id", Request::post("email"));
                 $user->set("password", Request::post("password"));
                 $user->set("re_pass", Request::post("r_password"));
                 $user->set("name", Request::post("name"));
                 $user->set("mobile", Request::post("mobile"));
                 $user->set("website", Request::post("website"));
                 $user->set("add", Request::post("add"));
                 $user->set("city", Request::post("city"));
                 $user->set("location", Request::post("location"));
                 $user->set("experience", Request::post("experience"));
                 $user->set("education", Request::post("education"));
                 $user->set("specialization", Request::post("specialization"));
                 $user->set("pra_court", Request::post("pra_court"));
                 $action = Request::post("action");
                 $result = $user->{$action}();
                 $page = new Page();
                 if ($result && $action == 'login') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/home";
                 } elseif ($result && $action == 'registration') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/home";
                 } elseif ($result && $action == 'editProfile') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/profile";
                 } else {
                     $r_url = SERVER_URL . "/login";
                 }
                 General::redirectUrl($r_url);
                 break;
             case 'company':
                 $company = new Company();
                 $company->set("user_id", Request::post("userid"));
                 $company->set("name", Request::post("name"));
                 $company->set("city", Request::post("city"));
                 $company->set("location", Request::post("location"));
                 $company->set("website", Request::post("website"));
                 $company->set("email", Request::post("email"));
                 $company->set("phone", Request::post("phone"));
                 $company->set("specialization", Request::post("specialization"));
                 $company->set("description", Request::post("description"));
                 $action = Request::post("action");
                 $result = $company->{$action}();
                 //                        print_r($result);                        exit();
                 $page = new Page();
                 if ($result && $action == 'addcompany') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/company";
                 } else {
                     $r_url = SERVER_URL . "/lpo-training";
                 }
                 General::redirectUrl($r_url);
                 break;
             case 'question':
                 $ques = new Questions();
                 $ques->set("user_id", Request::post("userid"));
                 $ques->set("question", Request::post("question"));
                 $ques->set("heading", Request::post("heading"));
                 $ques->set("topic_id", Request::post("topic_id"));
                 $ques->set("city", Request::post("city"));
                 $action = Request::post("action");
                 $result = $ques->{$action}();
                 //                       print_r($result);                        exit();
                 $page = new Page();
                 if ($result && $action == 'addquestion') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/online-legal-advice";
                 } else {
                     $r_url = SERVER_URL . "/home";
                 }
                 General::redirectUrl($r_url);
                 break;
             case 'jobs':
                 $job = new Jobs();
                 $job->set("user_id", Request::post("userid"));
                 $job->set("heading", Request::post("heading"));
                 $job->set("education", Request::post("education"));
                 $job->set("exp_min", Request::post("exp_min"));
                 $job->set("exp_max", Request::post("exp_max"));
                 $job->set("salary", Request::post("salary"));
                 $job->set("description", Request::post("description"));
                 $job->set("c_name", Request::post("companyname"));
                 $job->set("email", Request::post("email"));
                 $job->set("phone", Request::post("phone"));
                 $job->set("city", Request::post("city"));
                 $job->set("address", Request::post("address"));
                 $result = $company->{$action}();
                 //                        print_r($result);                        exit();
                 $page = new Page();
                 if ($result && $action == 'addjobs') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/jobs";
                 } else {
                     $r_url = SERVER_URL . "/{$pageType}/home";
                 }
                 General::redirectUrl($r_url);
                 break;
             case 'resumes':
                 $job = new Jobs();
                 $job->set("user_id", Request::post("userid"));
                 $job->set("heading", Request::post("heading"));
                 $job->set("education", Request::post("education"));
                 $job->set("exp_min", Request::post("exp_min"));
                 $job->set("exp_max", Request::post("exp_max"));
                 $job->set("salary", Request::post("salary"));
                 $job->set("description", Request::post("description"));
                 $job->set("c_name", Request::post("companyname"));
                 $job->set("email", Request::post("email"));
                 $job->set("phone", Request::post("phone"));
                 $job->set("city", Request::post("city"));
                 $job->set("address", Request::post("address"));
                 $result = $company->{$action}();
                 //                         print_r($result);                        exit();
                 $page = new Page();
                 if ($result && $action == 'addjobs') {
                     $page->set("access_id", Session::read("access_type"));
                     $pageType = $page->getPageTypeUrl();
                     $r_url = SERVER_URL . "/{$pageType}/jobs";
                 } else {
                     $r_url = SERVER_URL . "/{$pageType}/home";
                 }
                 General::redirectUrl($r_url);
                 break;
         }
     }
     $general = new General();
     $general->url = $url;
     return $general->setTempalte();
 }
if ($this->input->post->save_new_aanvraag) {
    // now we assume the form has been submitted.
    // tell the form to process input from the post vars.
    $form->processInput($this->input->post);
    // see if any errors occurred
    if (count($form->getErrors())) {
        $form->setMarkup(array('list' => "<div {attrs}>{out}</div>", 'item' => "<div {attrs}>{out}</div>"));
        // re-render the form, it will include the error messages
        $content = $form->render();
    } else {
        // successful form submission
        $np = new Page();
        // create new page object
        $np->template = $form->get("template_name")->value;
        // set template
        $np->parent = $pages->get('/aanvraag/');
        // set the parent
        $np->of(false);
        // turn off output formatting before setting values
        $np->save();
        foreach ($np->fields as $f) {
            $np->set($f->name, $form->get($f->name)->value);
        }
        $np->save();
        //create the page
        $content = "<p>Page saved.</p>";
    }
} else {
    $form->setMarkup(array('list' => "<div {attrs}>{out}</div>", 'item' => "<div {attrs}>{out}</div>"));
    $content = $form->render();
}
                        <a href="#">Add Page</a>
                    </li>
                </ul>
            </div>
            <div class="row">
                <div class="box col-md-12">
                    <div class="box-inner">
                        <div class="box-header well" data-original-title="">
                            <h2><i class="glyphicon glyphicon-edit"></i> Add Page </h2>
                        </div>
                        <div class="box-content">
                            <?php 
$id = Request::get("id");
if (is_numeric($id) && $id > 0) {
    $pageObj = new Page();
    $pageObj->set("page_id", $id);
    $result = $pageObj->getName();
    if (count($result)) {
        $row = $result[0];
        $page_id = $row['page_id'];
        $page_name = $row['name'];
        $category_id = $row['category_id'];
        $url = $row['url'];
        $top_description = $row['top_description'];
        $bottom_description = $row['bottem_description'];
        $keyword = $row['Keyword'];
        $title = $row['title'];
        $description = $row['description'];
        $author = $row['author'];
        $modified = $row['modified_by'];
        $access_type = $row['access_type'];
 public function setTempalte()
 {
     $notFoundPage = false;
     $id = 0;
     $urlArray = $this->splitPageUrl();
     $page = new Page();
     ob_start();
     if (count($urlArray) == 0 || $urlArray[0] == "home") {
         $page->set("url", "home");
         $templateFile = USER_TEMPLATE_FOLDER . '/index.php';
     } elseif (count($urlArray) == 1 && $urlArray[0] == "admin") {
         $templateFile = ADMIN_TEMPLATE_FOLDER . '/index.php';
     } elseif (count($urlArray) == 1 && $urlArray[0] != "admin") {
         $page->set("url", $urlArray[0]);
         $templateFile = USER_TEMPLATE_FOLDER . '/page.php';
     } elseif (count($urlArray) > 1 && count($urlArray) < 6 && $urlArray[0] != "admin") {
         $page->set("url", $urlArray[1]);
         $categoryDetails = $page->getPageCategoryId($urlArray[0]);
         if (count($categoryDetails)) {
             $page->set("category_id", $categoryDetails[0]['id']);
         }
         $templateFile = USER_TEMPLATE_FOLDER . '/page.php';
     } else {
         $notFoundPage = true;
     }
     $pageDetails = $page->getPageDetails();
     //print_r($pageDetails); exit;
     if (is_array($pageDetails) && count($pageDetails) && count($pageDetails[0])) {
         if ($pageDetails[0]["access_type"] == 1 && count($urlArray)) {
             switch ($urlArray[0]) {
                 case "login":
                     if (Session::isLogged()) {
                         $pageType = $page->getPageTypeUrl(Session::read("access_type"));
                         $url = SERVER_URL . "/{$pageType}/home";
                         General::redirectUrl($url);
                     }
                     break;
             }
         } elseif (isset($urlArray[1]) && !is_numeric($urlArray[1]) && count($urlArray) == 2 && $urlArray[1] == "logout") {
             //Logout
         } elseif (isset($urlArray[2]) && is_numeric($urlArray[2]) && $urlArray[2] > 0) {
             //User and Lawyer public profile using id
         } elseif (!Session::isLogged() && $pageDetails[0]["access_type"] > 1 && !is_numeric($urlArray[2])) {
             Error::set(INVALID_LOGIN);
             $url = SERVER_URL . "/login";
             General::redirectUrl($url);
         } elseif ($pageDetails[0]["access_type"] != Session::read("access_type") && Session::isLogged() && !is_numeric($urlArray[2])) {
             $pageType = $page->getPageTypeUrl(Session::read("access_type"));
             $url = SERVER_URL . "/{$pageType}/home";
             General::redirectUrl($url);
         }
         if (!$notFoundPage) {
             if (count($urlArray) > 1) {
                 $pageCnt = self::useClass($urlArray);
                 //print_r($pageCnt); exit;
                 if (!$pageCnt) {
                     $notFoundPage = true;
                 }
             }
             if (!$notFoundPage) {
                 include $templateFile;
             }
         }
     } else {
         $notFoundPage = true;
     }
     if ($notFoundPage) {
         Error::notFoundPage();
     }
     $contents = ob_get_contents();
     ob_clean();
     return $contents;
 }
 function output_file(&$menu_array, $rel_path = '/')
 {
     $page = new Page($this->name . ' \\ Examples', $this->sub, "", "../");
     $page->subtemplate('template.example.html');
     $page->content($this->display());
     $page->set('examples_nav', $this->back_to_list());
     //writeFile("learning/".strtolower($this->sub)."/".strtolower($this->name).".html", $page->out());
     // Move 2 May 2013
     writeFile("examples/" . strtolower($this->name) . ".html", $page->out());
     $this->copy_media();
     echo $this->name . '<br />';
     #echo "learning/examples/".strtolower($this->sub)."/".strtolower($this->name).".html\n";
 }
Example #17
0
 /**
  * Auto-populate some fields for a new page that does not yet exist
  *
  * Currently it does this: 
  * - Sets up a unique page->name based on the format or title if one isn't provided already. 
  * - Assigns a 'sort' value'. 
  * 
  * @param Page $page
  *
  */
 public function ___setupNew(Page $page)
 {
     if (!$page->parent()->id) {
         // auto-assign a parent, if we can find one in family settings
         $parentTemplates = $page->template->parentTemplates;
         $parent = null;
         if (!empty($parentTemplates)) {
             $idStr = implode('|', $parentTemplates);
             $parent = $this->get("include=hidden, template={$idStr}");
             if (!$parent->id) {
                 $parent = $this->get("include=all, template={$idStr}");
             }
         }
         if ($parent->id) {
             $page->parent = $parent;
         }
     }
     if (!$page->name) {
         // auto-assign a name if possible
         $format = $page->parent()->template->childNameFormat;
         $pageName = '';
         if (strlen($format)) {
             if ($format == 'title') {
                 if (strlen($page->title)) {
                     $pageName = $page->title;
                 } else {
                     $pageName = $this->_('untitled');
                 }
             } else {
                 if (!ctype_alnum($format) && !preg_match('/^[-_a-zA-Z0-9]+$/', $format)) {
                     // it is a date format
                     $pageName = date($format);
                 } else {
                     // predefined format
                     $pageName = $format;
                 }
             }
         } else {
             if (strlen($page->title)) {
                 $pageName = $page->title;
             } else {
                 // no name will be assigned
             }
         }
         if (strlen($pageName)) {
             // make the name unique
             $pageName = $this->wire('sanitizer')->pageName($pageName, Sanitizer::translate);
             $numChildren = $page->parent->numChildren();
             $n = 0;
             do {
                 $name = $pageName;
                 if ($n > 0) {
                     $name .= "-" . ($numChildren + $n);
                 }
                 $child = $page->parent->child("name={$name}, include=all");
                 // see if another page already has the same name
                 $n++;
             } while ($child->id);
             $page->name = $name;
             $page->set('_hasAutogenName', true);
             // for savePageQuery, provides adjustName behavior for new pages
         }
     }
     if ($page->sort < 0) {
         // auto assign a sort
         $page->sort = $page->parent->numChildren();
     }
 }