Пример #1
0
 /**
  * @var CActiveForm form
  */
 public function run()
 {
     $model = new Cms();
     $art_list = $model->getPageList();
     foreach ($art_list as $art) {
         echo "<a href='" . Yii::app()->baseUrl . "/" . $art->url . "'>" . $art->name . "</a>";
     }
 }
Пример #2
0
 public function about()
 {
     $title = "About Page";
     $page_active = "about";
     $content = Cms::where('tag', 'about')->where('status', 1)->first();
     return view('pages.about', compact('title', 'page_active', 'content'));
 }
Пример #3
0
 /**
  * 实例化对像
  * 
  * @return class
  */
 public static function factory()
 {
     if (!isset(self::$_class)) {
         $className = __CLASS__;
         self::$_class = new $className();
     }
     self::$menu = new Rms();
     return self::$_class;
 }
Пример #4
0
 public function run()
 {
     Yii::import('application.modules.cms.models.*');
     $this->model = Cms::model()->findByPK($this->parent_id);
     $tree = $this->getTreeViewData($this->showRoot, 'name');
     if ($this->tpl) {
         $this->render($this->tpl, array('tree' => $tree));
     } else {
         $this->widget('CTreeView', array('data' => $tree, 'animated' => false, 'persist' => 'location'));
     }
 }
Пример #5
0
 public static function smartTags($app, $data)
 {
     $data = Cms::twSlider($app, $data);
     preg_match_all("/\\[\\[[a-zA-Z]*\\]\\]/", $data, $res);
     foreach ($res[0] as $tag) {
         $stripped = str_replace(array("[", "]"), "", $tag);
         $cnt = $app['twig']->render($stripped . '.twig');
         $data = str_replace($tag, $cnt, $data);
     }
     return $data;
 }
Пример #6
0
 private function getMenu()
 {
     if ($items = Cms::model()->findAllByAttributes($this->attributes)) {
         $menu = array();
         $menu[] = array('label' => 'Home', 'url' => array('/'));
         foreach ($items as $item) {
             $menu[] = array('label' => $item->name, 'url' => array('/' . $item->url));
         }
         return $menu;
     }
     return array();
 }
Пример #7
0
 public function __construct($config)
 {
     $session = session('web');
     $session->setLanguage($config->getLanguage());
     $this->_config = $config;
     if ($config->getLanguage() == Cms::getOption('default_language')) {
         $this->_needTranslate = false;
     } else {
         $file = APPLICATION_PATH . DS . SITE_NAME . DS . 'modules' . DS . $config->getModule() . DS . 'languages' . DS . $config->getController() . ucFirst($config->getLanguage()) . '.php';
         $this->_translation = new languageTranslation();
         if (File::exists($file)) {
             $translation = (include $file);
             $this->_translation->populate(Arrays::exists($config->getAction(), $translation) ? $translation[$config->getAction()] : $translation);
         }
     }
 }
Пример #8
0
 function cmsData()
 {
     $cmsData = Cms::get();
     $rootData = $cmsData['root'];
     $sysData = $cmsData['sysInfo'];
     if (!is_array($rootData)) {
         $rootData = json_decode($rootData, true);
     }
     if (!is_array($sysData)) {
         $sysData = json_decode($sysData, true);
     }
     $this->smarty->cmsdata = $rootData;
     $this->cmsdata = $rootData;
     $this->smarty->assign('root', $rootData);
     $this->smarty->assign('body', $rootData['body']);
     $this->smarty->assign('head', $rootData['head']);
     $this->smarty->assign('foot', $rootData['foot']);
     $this->smarty->assign('sysInfo', $sysData);
 }
function __($value)
{
    // Ponemos la cadena en mayusculas y sustituimos los espacios por "_"
    $value = strtoupper(str_replace(' ', '_', $value));
    foreach ($GLOBALS['translations'] as $cms) {
        if (strcasecmp($cms->name, $value) == 0 && trim($cms->value != "")) {
            return $cms->value;
        }
    }
    // Si no encontramos la cadena creamos el registro en la BBDD y
    // devolvemos el $value original con % % para detectarlo
    if (!Cms::byName($value)) {
        $new_cms = new Cms();
        $cms->name = $value;
        $cms->value = '';
        $cms->insert();
    }
    return '%' . $value . '%';
    //'';
}
Пример #10
0
 public function __construct()
 {
     parent::__construct();
     $this->design_page_name = '';
     $this->add_event(PAGE_INIT, 'check_login');
     $this->add_event(PAGE_INIT, 'on_init');
     $this->add_event(AJ_INIT, 'ajax_check_login');
     if ($dh = opendir(CMS . 'modules/')) {
         while (($name = readdir($dh)) !== false) {
             if (is_dir(CMS . 'modules/' . $name)) {
                 if (@file_exists(CMS . 'modules/' . $name . '/admin.php')) {
                     require_once CMS . 'modules/' . $name . '/admin.php';
                     $class_name = Cms::capitalize_words($name) . 'AdminModule';
                     $this->modules[$name] = new $class_name();
                     $this->modules[$name]->owner = $this;
                 }
             }
         }
         closedir($dh);
         foreach ($this->modules as $module) {
             $module->register();
         }
     }
 }
Пример #11
0
}
require BASE_DIR . INCLUDE_DIR . 'parameters.php';
require BASE_DIR . INCLUDE_DIR . 'db.php';
require BASE_DIR . FRONTEND_DIR . 'site.php';
require BASE_DIR . MODULE_DIR . 'administrator/log/module.php';
require BASE_DIR . INCLUDE_DIR . 'error_handler.php';
require BASE_DIR . BACKEND_DIR . 'cms.php';
require BASE_DIR . BACKEND_DIR . 'db.php';
$parametersMod = new \ParametersMod();
if (\Db::connect()) {
    header('X-UA-Compatible: IE=EmulateIE7');
    $log = new \Modules\Administrator\Log\Module();
    $site = new \Frontend\Site();
    /*to generate links to site and get other data about frontend*/
    $site->init();
    $cms = new Cms();
    ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>ImpressPages CMS</title>
    <link rel="SHORTCUT ICON" href="favicon.ico" />
</head>
<frameset rows="64px,*" framespacing="0" border="0">
 <frame name="header" noresize="noresize" frameborder=0 scrolling="no" src="<?php 
    echo $cms->generateActionurl('tep_modules');
    ?>
">
 <frame id="frameContent" name="content" frameborder=0 src="<?php 
    echo $cms->generateActionurl('first_module');
Пример #12
0
 protected function on_init()
 {
     $this->vars['content'] = '';
     if (strlen(_GET('node_id'))) {
         $node = new Node();
         if (!$node->find_by_id(_GET('node_id'))) {
             return;
         }
         if (!array_key_exists($node->type, $this->modules)) {
             return;
         }
         $this->vars['content'] = $this->modules[$node->type]->render_editor($node);
     } elseif (strlen(_GET('parent_id'))) {
         $parent_node = new Node();
         if (!$parent_node->find_by_id(_GET('parent_id'))) {
             return;
         }
         if (array_key_exists($parent_node->type, $this->modules)) {
             if (!$this->modules[$parent_node->type]->can_has_childs($parent_node)) {
                 return;
             }
             $type = $this->modules[$parent_node->type]->get_new_node_type($parent_node, $parent_node->type);
         } else {
             $type = '';
             foreach ($this->modules as $mtype => $module) {
                 if ($module->get_tree_subpath() != '' && Cms::path_start_with($parent_node->full_path, $module->get_tree_subpath(), true)) {
                     $type = $module->get_new_node_type($parent_node, $mtype);
                     break;
                 }
             }
         }
         if ($type == '') {
             return;
         }
         $node = new Node();
         $node->type = $type;
         $node->flags = Node::Visible | Node::UserChilds;
         $node->path = $parent_node->full_path . '/';
         $this->vars['content'] = $this->modules[$type]->render_editor($node);
     } elseif (strlen(_GET('module')) && strlen(_GET('item_id'))) {
         if (!array_key_exists(_GET('module'), $this->modules)) {
             return;
         }
         require_once CMS . 'modules/' . _GET('module') . '/admin.php';
         $class_name = $this->modules[_GET('module')];
         $module = new $class_name();
         $module->owner = $this;
         $this->vars['content'] = $module->render_nav_editor(_GET('item_id'));
     }
 }
Пример #13
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     return parent::find()->where(['type' => [static::AD_TYPE_CAROUSE, static::AD_TYPE_HTML]]);
 }
Пример #14
0
 /**
  * Modify User POST
  */
 function modcms()
 {
     $clang = Yii::app()->lang;
     $page_id = flattenText($_POST['page_id'], false, true, 'UTF-8', true);
     $page_name = flattenText($_POST['page_name'], false, true, 'UTF-8', true);
     $page_title = flattenText($_POST['page_title'], false, true, 'UTF-8', true);
     $page_meta = flattenText($_POST['page_meta'], false, true, 'UTF-8', true);
     $page_language = Yii::app()->request->getPost("page_language");
     $page_type = flattenText($_POST['page_type'], false, true, 'UTF-8', true);
     $shwmenu = flattenText(Yii::app()->request->getPost("shwmenu"));
     $shw_menu = 0;
     if ($shwmenu) {
         $shw_menu = 1;
     }
     if ($page_type == 1) {
         $page_content = $_POST['page_content'];
     } elseif ($page_type == 2) {
         $page_content = flattenText($_POST['redirectlink'], false, true, 'UTF-8', true);
     }
     $IsActive = flattenText(Yii::app()->request->getPost("IsActive"));
     $aViewUrls = array();
     $is_Active = 0;
     if ($IsActive) {
         $is_Active = 1;
     }
     $sresult = Cms::model()->findAllByAttributes(array('page_id' => $page_id));
     $sresultcount = count($sresult);
     if (Permission::model()->hasGlobalPermission('superadmin', 'read') || $sresultcount > 0 && Permission::model()->hasGlobalPermission('CMS', 'update')) {
         if ($page_name == '') {
             $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing page"), $clang->gT("Could not modify Contact."), "warningheader", $clang->gT("Page name not be empty."), $this->getController()->createUrl('admin/cms/sa/modifycms'), $clang->gT("Back"), array('page_id' => $page_id));
         } else {
             $oRecord = Cms::model()->findByPk($page_id);
             $oRecord->page_name = $page_name;
             $oRecord->page_title = $page_title;
             $oRecord->contenttype = $page_type;
             $oRecord->showinmenu = $shw_menu;
             $oRecord->IsActive = $is_Active;
             $EditContact = $oRecord->save();
             if ($EditContact) {
                 // When saved successfully
                 $sql = "SELECT count(*) as cnt FROM {{cms_page_content}}\n                            WHERE page_id = '{$page_id}' AND language_code = '{$page_language}'";
                 $result = Yii::app()->db->createCommand($sql)->queryRow();
                 if ($result['cnt'] > 0) {
                     $sqlupdate = "UPDATE {{cms_page_content}} SET\n                                    page_content = '" . str_replace("'", "&#39", $page_content) . "'\n                                    , meta_tags = '{$page_meta}'\n                                    WHERE page_id = '{$page_id}' AND language_code = '{$page_language}'";
                     $result = Yii::app()->db->createCommand($sqlupdate)->query();
                 } else {
                     $sqlupdate = "INSERT INTO {{cms_page_content}} (page_id,language_code,page_content,meta_tags) \n                                VALUES('{$page_id}', '{$page_language}', '" . str_replace("'", "&#39", $page_content) . "', '{$page_meta}');";
                     $result = Yii::app()->db->createCommand($sqlupdate)->query();
                 }
                 Yii::app()->setFlashMessage($clang->gT("Page updated successfully"));
                 $this->getController()->redirect(array("admin/cms/index"));
             } else {
                 $aViewUrls['mboxwithredirect'][] = $this->_messageBoxWithRedirect($clang->gT("Editing Page"), $clang->gT("Could not modify Page."), 'warningheader');
             }
         }
     } else {
         Yii::app()->setFlashMessage(Yii::app()->lang->gT("You do not have sufficient rights to access this page."), 'error');
         $this->getController()->redirect(array("admin/index"));
     }
     $this->_renderWrappedTemplate('cms', $aViewUrls);
 }
Пример #15
0
// make sure other files are accessed through this file.
define('BACKEND', true);
// make sure other files are accessed through this file.
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', '1');
if (is_file(__DIR__ . '/ip_config.php')) {
    require __DIR__ . '/ip_config.php';
} else {
    require __DIR__ . '/../ip_config.php';
}
require BASE_DIR . INCLUDE_DIR . 'parameters.php';
require BASE_DIR . INCLUDE_DIR . 'db.php';
require BASE_DIR . FRONTEND_DIR . 'site.php';
require BASE_DIR . MODULE_DIR . 'administrator/log/module.php';
require BASE_DIR . INCLUDE_DIR . 'error_handler.php';
require BASE_DIR . BACKEND_DIR . 'cms.php';
require BASE_DIR . BACKEND_DIR . 'db.php';
$parametersMod = new \ParametersMod();
if (\Db::connect()) {
    header('X-UA-Compatible: IE=EmulateIE7');
    $log = new \Modules\Administrator\Log\Module();
    $site = new \Frontend\Site();
    /*to generate links to site and get other data about frontend*/
    $site->init();
    $cms = new Cms();
    $cms->makeActions();
    $cms->manage();
    \Db::disconnect();
} else {
    trigger_error('Database access');
}
Пример #16
0
$profile = new User();
$validuser = $profile->userprofile($_SESSION['userid']);
if (empty($validuser->name)) {
    session_destroy();
    header("Location: index.php");
}
$userid = $_SESSION['userid'];
// My Profile
$myprofile = $profile->userprofile($userid);
// My Score
$myscore = $profile->myscore($userid);
// Team Score
$totalteamscore = $profile->teamscore($myprofile->team);
$_SESSION['teamid'] = $myprofile->team;
// Get Questions
$q = new Cms();
$userquestions = $q->getweekquestion();
include_once 'header.php';
?>
<!--
	<div class="breadcrumbs">
		<section class="container">
			<div class="row">
				<div class="col-md-12">
					<h1>User Profile : <?php 
//echo $myprofile->name;
?>
</h1>
				</div>
				<div class="col-md-12">
					<div class="crumbs">
Пример #17
0
 protected function load_modules()
 {
     $cached_list_path = conf('cache.path') . 'modules.list';
     if (@file_exists($cached_list_path)) {
         $cached_list = unserialize(file_get_contents($cached_list_path));
         foreach ($cached_list as $name) {
             require_once CMS . 'modules/' . $name . '/module.php';
             $class_name = Cms::capitalize_words($name) . 'Module';
             $this->modules[$name] = new $class_name($this);
         }
         return;
     }
     $avail_modules = array();
     if ($dh = opendir(CMS . 'modules/')) {
         while (($name = readdir($dh)) !== false) {
             if (is_dir(CMS . 'modules/' . $name)) {
                 if (@file_exists(CMS . 'modules/' . $name . '/module.php')) {
                     require_once CMS . 'modules/' . $name . '/module.php';
                     $class_name = Cms::capitalize_words($name) . 'Module';
                     $before = array();
                     $after = array();
                     if (is_callable(array($class_name, '_before'))) {
                         $before = call_user_func(array($class_name, '_before'));
                         if (!is_array($before)) {
                             $before = array($before);
                         }
                     }
                     if (is_callable(array($class_name, '_after'))) {
                         $after = call_user_func(array($class_name, '_after'));
                         if (!is_array($after)) {
                             $after = array($after);
                         }
                     }
                     $avail_modules[$name] = array('class' => $class_name, 'before' => $before, 'after' => $after);
                 }
             }
         }
         closedir($dh);
     }
     foreach ($avail_modules as $mod_name => $item) {
         foreach ($item['after'] as $name) {
             if (!array_key_exists($name, $avail_modules)) {
                 throw new Exception("\"{$mod_name}\" depends on \"{$name}\", but \"{$name}\" not found");
             }
         }
     }
     foreach ($avail_modules as $mod_name => $item) {
         foreach ($item['before'] as $name) {
             if (array_key_exists($name, $avail_modules)) {
                 if (!in_array($mod_name, $avail_modules[$name]['after'])) {
                     $avail_modules[$name]['after'][] = $mod_name;
                 }
             }
         }
     }
     $cached_list = array();
     for (;;) {
         $has_changes = false;
         $has_modules = false;
         foreach ($avail_modules as $mod_name => $item) {
             if (array_key_exists($mod_name, $this->modules)) {
                 continue;
             }
             $has_modules = true;
             $can_insert = true;
             foreach ($item['after'] as $name) {
                 if (!array_key_exists($name, $this->modules)) {
                     $can_insert = false;
                     break;
                 }
             }
             if (!$can_insert) {
                 continue;
             }
             $class_name = $item['class'];
             $this->modules[$mod_name] = new $class_name($this);
             $cached_list[] = $mod_name;
             $has_changes = true;
         }
         if (!$has_modules) {
             break;
         }
         if (!$has_changes) {
             throw new Exception("Can't resolve modules dependencies");
         }
     }
     if ($fp = @fopen($cached_list_path, 'wb')) {
         fwrite($fp, serialize($cached_list));
         fclose($fp);
         chmod($cached_list_path, 0555 + 0111);
     }
     $avail_modules = null;
 }
Пример #18
0
 protected function install($module)
 {
     $node = Node::get_node('site');
     if (!$node) {
         $this->message('Creating root node');
         Node::create_node(Node::Folder, 'site', conf_get('sitename'), Node::Visible | Node::System);
     } else {
         $this->message('Updating root node');
         $node->title = conf_get('sitename');
         $node->save();
     }
     if ($module) {
         $this->call_module_method($module, 'module_install', 'Installing');
         return;
     }
     if (!($dh = opendir(CMS . 'modules/'))) {
         $this->message('"' . CMS . 'modules/" not found');
         return;
     }
     $avail_modules = array();
     while (($module = readdir($dh)) !== false) {
         if (!is_dir(CMS . "modules/{$module}") || !is_readable(CMS . "modules/{$module}/admin.php")) {
             continue;
         }
         require_once CMS . "modules/{$module}/admin.php";
         $class_name = Cms::capitalize_words($module) . 'AdminModule';
         if (!is_callable(array($class_name, 'module_install'))) {
             continue;
         }
         $before = array();
         $after = array();
         if (is_callable(array($class_name, '_before'))) {
             $before = call_user_func(array($class_name, '_before'));
             if (!is_array($before)) {
                 $before = array($before);
             }
         }
         if (is_callable(array($class_name, '_after'))) {
             $after = call_user_func(array($class_name, '_after'));
             if (!is_array($after)) {
                 $after = array($after);
             }
         }
         $avail_modules[$module] = array('class' => $class_name, 'before' => $before, 'after' => $after);
     }
     closedir($dh);
     foreach ($avail_modules as $mod_name => $item) {
         foreach ($item['after'] as $name) {
             if (!array_key_exists($name, $avail_modules)) {
                 $this->message("\"{$mod_name}\" depends on \"{$name}\", but \"{$name}\" not found");
                 return;
             }
         }
     }
     foreach ($avail_modules as $mod_name => $item) {
         foreach ($item['before'] as $name) {
             if (array_key_exists($name, $avail_modules)) {
                 if (!in_array($mod_name, $avail_modules[$name]['after'])) {
                     $avail_modules[$name]['after'][] = $mod_name;
                 }
             }
         }
     }
     $modules_list = array();
     $modules_hash = array();
     for (;;) {
         $has_changes = false;
         $has_modules = false;
         foreach ($avail_modules as $mod_name => $item) {
             if (array_key_exists($mod_name, $modules_hash)) {
                 continue;
             }
             $has_modules = true;
             $can_insert = true;
             foreach ($item['after'] as $name) {
                 if (!array_key_exists($name, $modules_hash)) {
                     $can_insert = false;
                     break;
                 }
             }
             if (!$can_insert) {
                 continue;
             }
             $class_name = $item['class'];
             $modules_hash[$mod_name] = true;
             $modules_list[] = $mod_name;
             $has_changes = true;
         }
         if (!$has_modules) {
             break;
         }
         if (!$has_changes) {
             $this->message("Can't resolve modules dependencies");
             return;
         }
     }
     foreach ($modules_list as $module) {
         $this->call_module_method($module, 'module_install', 'Installing');
     }
 }
Пример #19
0
 function isTaken()
 {
     $this->normalizeUrl();
     $params = array(':url' => $this->url, ':type_link' => self::LINK);
     if (!$this->getIsNewRecord()) {
         $params[':id'] = $this->id;
         $idCond .= ' AND id!=:id';
     }
     $count = Cms::model()->count('url=:url AND type!=:type_link' . $idCond, $params);
     return $count;
 }
Пример #20
0
 public function actionGetParentUrl()
 {
     $parentId = $_POST['parent_id'];
     $parent = Cms::model()->findByPk($parentId);
     if ($parent && $parent->url) {
         echo $parent->url . '/';
     }
 }
Пример #21
0
 static function getCms()
 {
     $dataRoot = dirname(__FILE__) . "/";
     $privateDataDir = DATA_ROOT . self::$dataDir;
     $publicDataDir = DATA_ROOT . rtrim(self::$dataRoot, "/") . "/base/";
     $dataName = "data.php";
     //指定data的路径(仅能指定同目录下私有数据)
     $assignDataName = $_GET["data"];
     if (!empty($assignDataName)) {
         $dataName = $assignDataName . ".php";
     }
     //复制url的参数值到$root.urlparam中
     $arr = array("urlparam" => array_merge($_GET, $_POST));
     //set smarty
     $sysInfo = array("baseDataDir" => $publicDataDir . "data\\.php", "privateDataDir" => $privateDataDir . "data\\.php", "templateRoot" => TEMPLATE_PATH, "country" => self::$country, "host" => self::$host);
     //获取query_string以便判断是否开启smarty或者data调试模式
     if (isset($_SERVER['QUERY_STRING'])) {
         self::$_query_string = $_SERVER['QUERY_STRING'];
     }
     //判断是否启动smarty调试
     self::isSmartyDebug();
     //所有data都有一个公共data,先把公共的data加载到cmsdata中
     $severBaseDataPath = rtrim(self::$dataRoot, "/") . "/base/" . self::$serverDataName;
     $localBaseDataPath = $publicDataDir . self::$dataName;
     $arr = CmsDataAdapter::saveAndGetOrMergeData($localBaseDataPath, $severBaseDataPath, $arr);
     //如果指定私有数据路径使用私有数据
     if (strpos(self::$dataDir, 'fetchwidget') !== false) {
         $assignDir = $_GET['dataDir'];
         if (!$assignDir) {
             $assignDir = "index";
         }
         $privateDataDir = DATA_ROOT . self::$dataRoot . $assignDir . "/";
     }
     $severPrivateDataPath = self::$dataDir . self::$serverDataName;
     $localPrivateDataPath = $privateDataDir . self::$dataName;
     $arrTmp = CmsDataAdapter::saveAndGetOrMergeData($localPrivateDataPath, $severPrivateDataPath, $arrTmp);
     if (!empty($arrTmp['head']['privateBaseData'])) {
         $serverPrivateBaseDataPath = $arrTmp["head"]["privateBaseData"];
         $localPrivateBaseDataPath = DATA_ROOT . $arrTmp["head"]["privateBaseData"];
         $arr = CmsDataAdapter::saveAndGetOrMergeData($localPrivateBaseDataPath, $serverPrivateBaseDataPath, $arr);
     }
     $arr = self::array_merge_recursive_new($arr, $arrTmp);
     //这个数据流程为总base-》指定base-》页面数据
     $severPrivateDataPath = self::$dataDir . self::$serverDataName;
     $localPrivateDataPath = $privateDataDir . self::$dataName;
     //支持选择性的三层数据继承 遗留bug ,这个数据流程为总base->页面数据-》指定base
     if (!empty($arr["head"]["baseData"])) {
         $baseData = $sysInfo["privateDataDir"] = DATA_ROOT . $arr["head"]["baseData"];
         $severPrivateDataPath = $arr["head"]["baseData"];
         $arr = CmsDataAdapter::saveAndGetOrMergeData($baseData, $severPrivateDataPath, $arr);
     }
     //支持第三层数据继承,为了抽样
     $sample = empty($_GET['sample']) ? "" : $_GET['sample'];
     if (!empty($sample) && !empty($arr["head"]["sample"][$sample])) {
         ////////////////////////////
         //支持子通道(返回功能)
         $sub_channel_cookie = 'sample_channel_' . $sample;
         //=back';
         $sub_sample_name = $_COOKIE[$sub_channel_cookie];
         if (!empty($sub_sample_name)) {
             $sample = $sample . '_' . $sub_sample_name;
             //'searchtest' => 'searchtest_back'
         }
         /////////////////
         $sampleDir = ltrim($arr["head"]["sample"][$sample], "/");
         $sampleDataPath = $sysInfo["privateDataDir"] = DATA_ROOT . $sampleDir;
         //fis需要转移"."为"\."
         $sysInfo["privateDataDir"] = str_replace('data.php', 'data\\.php', $sysInfo["privateDataDir"]);
         $baseData = $sysInfo["privateDataDir"] = DATA_ROOT . $arr["head"]["baseData"];
         $serverSampleDataPath = $sampleDir;
         $arr = CmsDataAdapter::saveAndGetOrMergeData($sampleDataPath, $serverSampleDataPath, $arr);
     }
     ///////////////////////////////////////////////////////
     //支持读取外部数据的插件机制
     if (isset($arr['body']['extendDataPlugin']) && $arr['body']['extendDataPlugin']['on']) {
         $extend_data_plugins = $arr['body']['extendDataPlugin']['plugins'];
         //
         /*array(
               array(
                   'start' => 0,
                   'end' => 2395212684,
                   'sample_name' => '',
                   'params' => '{}',
                   'name' => 'recommendhottab'
               )
           );*/
         $action_time = time();
         foreach ($extend_data_plugins as $api_plugin) {
             if ($api_plugin['need_baiduid'] && empty($_COOKIE['BAIDUID'])) {
                 //判断是否有baiduid
                 continue;
             }
             if ($api_plugin['start'] <= $action_time && $action_time <= $api_plugin['end']) {
                 //判断插件生效时间,用timestamp
                 //正式开始引入插件处理
                 $params = $api_plugin['params'];
                 if (!empty($params)) {
                     try {
                         $params = json_decode($params, true);
                     } catch (Exception $e) {
                         $params = array();
                     }
                 } else {
                     $params = array();
                 }
                 $api_plugin_name = $api_plugin['name'];
                 $api_plugin_class = ucfirst($api_plugin_name);
                 try {
                     $api_plugin_config = (include_once $dataRoot . 'plugin/' . $api_plugin_name . '/' . $api_plugin_class . '.inc.php');
                 } catch (Exception $e) {
                     //TODO LOG
                     continue;
                 }
                 if (empty($api_plugin_config)) {
                     continue;
                     //配置不合法,退出
                 }
                 try {
                     include_once $dataRoot . '/plugin/' . $api_plugin_name . '/' . $api_plugin_class . '.class.php';
                 } catch (Exception $e) {
                     //TODO LOG
                     continue;
                 }
                 if (!class_exists($api_plugin_class)) {
                     continue;
                     //类加载有问题,退出
                 }
                 $api_plugin_instance = new $api_plugin_class($api_plugin_config, $sysInfo['country']);
                 if (empty($api_plugin_instance)) {
                     continue;
                     //初始化失败,退出
                 }
                 $ret = $api_plugin_instance->process($arr['body'], $params);
                 //执行数据干预
                 if ($ret === false) {
                     //LOG
                 }
             }
         }
     }
     //smarty extend(为了选择布局)不能用条件判断语句,但是可以使用变量
     $layoutRoot = "web/base/layout/";
     $sysInfo['layout'] = empty($arr["head"]["layout"]) ? "home/page/layout/layout-index.tpl" : $arr["head"]["layout"];
     // 把cookie记录到smarty变量中,方便前端模板调用
     $baiduId = $sysInfo["baiduid"] = isset($_COOKIE["FLASHID"]) ? $_COOKIE["FLASHID"] : (isset($_COOKIE["BAIDUID"]) ? $_COOKIE["BAIDUID"] : "");
     $sysInfo["serverTime"] = time();
     //测试环境,需要置空cdn
     $arr["head"]["cdn"] = "";
     if (!empty($baiduId) && extension_loaded("decodecookie")) {
         $sysInfo["baiduidCt"] = decodecookie($baiduId);
     } else {
         $sysInfo["baiduidCt"] = $sysInfo["serverTime"];
     }
     self::$cmsData = array("sysInfo" => $sysInfo, "root" => $arr);
 }
Пример #22
0
 public static function renderHomePage()
 {
     $cmsHandler = new CmsHandler();
     $page = Cms::model()->findByPk(1);
     $cmsHandler->processCms($page);
 }
Пример #23
0
$app->get('/blog/{postslug}/', function ($postslug) use($app) {
    $data = collection("posts")->findOne(["Title_slug" => $postslug]);
    if ($data === null) {
        $app->abort(404, "Post '{$postslug}' does not exist.");
    }
    return $app['twig']->render('post.twig', array('data' => $data));
});
$app->get('/portfolio/', function () use($app) {
    $data = gallery("Portfolio");
    d($data);
    return $app['twig']->render('gallery.twig', array('data' => $data));
});
$app->get('/cv/', function () use($app) {
    $content = Cms::curlGet(CV_URL . ".md");
    $content = cockpit("cockpit")->markdown($content);
    $content = Cms::cleanHtml($content);
    $data = ["Title" => "Curriculum Vitae", "Subtitle" => "Lorem ipsum", "content" => "<section class='cv'>" . $content . "</section>"];
    d($data);
    return $app['twig']->render('page.twig', array('data' => $data));
});
$app->get('/{pageslug}/', function ($pageslug) use($app) {
    $data = collection("Pages")->findOne(["Title" => $pageslug]);
    if ($data === null) {
        $data = collection("Pages")->findOne(["Title_slug" => $pageslug]);
    }
    if ($data === null) {
        $app->abort(404, "Page '{$pageslug}' does not exist.");
    }
    return $app['twig']->render('page.twig', array('data' => $data));
});
$app->error(function (\Exception $e, $code) use($app) {
Пример #24
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Cms the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Cms::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #25
0
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * Zame CMS
 */
require_once dirname(__FILE__) . '/../../s/s.php';
require_once BASE . 'inc/core/core.php';
require_once CMS . 'core/base_command.php';
if (!isset($argc) || $argc < 2) {
    echo "Usage: php run.php <command> [command-arguments]\n";
    exit;
}
$command_path = CMS . "modules/{$argv[1]}/command.php";
if (!is_readable($command_path)) {
    echo "{$command_path} not found\n";
    exit;
}
require_once $command_path;
$class_name = Cms::capitalize_words($argv[1]) . 'Command';
$command = new $class_name();
if (!$command instanceof BaseCommand) {
    echo "{$class_name} does not extend BaseCommand\n";
    exit;
}
echo "[+ {$class_name}]\n";
$command->run(array_slice($argv, 2));
echo "[- {$class_name}]\n";
Пример #26
0
 /**
  * Rebuild cache files for all module settings
  */
 public function actionRebuildCache()
 {
     $result = Cms::service('Cms/Settings/rebuildCache', array());
     $this->message = 'Cache is updated for pages, categories, system and all modules settings.';
     $this->redirect($this->createUrl('/BackOffice/admin/modules/dashboard', array('module' => 'Cms')));
 }
Пример #27
0
 private function get_structure_difference()
 {
     // Список таблиц
     $tables = Cms_Structure::get_all_tables();
     $db_data = array();
     $db_tables = array_diff(Cms::get_dal_instance()->get_tables(), Cms::get_ignore_tables());
     foreach ($db_tables as $db_table_name) {
         $db_data[$db_table_name] = Cms::get_dal_instance()->get_columns($db_table_name);
     }
     $structure_table_names = Cms_Structure::get_all_table_names();
     $to_del = array();
     $to_add = array_diff($db_tables, $structure_table_names);
     $to_change = array();
     foreach ($tables as $table) {
         $alias = $table->get_alias();
         $tname = $table->get_table_name();
         // Если таблица есть в БД - сравниваем столбцы
         if (array_key_exists($tname, $db_data)) {
             $tcolumns = $table->get_columns();
             $db_columns = $db_data[$tname];
             // Если столбцы в БД и в файле структуры различаются - требуются изменения
             if (array_keys($tcolumns) != array_keys($db_columns)) {
                 $to_change[] = $alias;
             }
         } else {
             $to_del[] = $alias;
         }
     }
     $result = array('tables' => $tables, 'db_data' => $db_data, 'to_add' => $to_add, 'to_del' => $to_del, 'to_change' => $to_change);
     return $result;
 }
Пример #28
0
        $category_id = (int) $category_id;
        $query = $pdo->prepare('SELECT * FROM articles WHERE article_category = ? ORDER BY article_id ' . $val);
        $query->bindValue(1, $category_id);
        $query->execute();
        return $query->fetchAll();
    }
    // fetch article with id number
    public function fetch_article($id = '1')
    {
        global $pdo;
        $id = (int) $id;
        $query = $pdo->prepare("SELECT * FROM articles WHERE article_id = ?");
        $query->bindValue(1, $id);
        $query->execute();
        return $query->fetchAll();
    }
}
?>


// Simple use cms class
<?php 
$perpage = 44;
$page = '1';
$catid = '2';
if (isset($_GET['page'])) {
    $page = (int) $_GET['page'];
}
$article = new Cms();
$articles = $article->fetch_all_pagine_cat($catid, $page, $perpage);
$cat = $article->fetch_category();
Пример #29
0
 public function __set($name, $value)
 {
     if ($name != 'Value') {
         return parent::__set($name, $value);
     }
     $meta = $this->Meta;
     if ($meta['writer'] != '') {
         $result = Cms::rawService($meta['writer'], array('Value' => $value));
         if ($result->ReturnCode == ServiceResult::RETURN_SUCCESS) {
             $value = $result->ReturnedData['Value'];
         } else {
             $this->addError('Value', $result->ErrorMessages[0]);
         }
     }
     return parent::__set($name, $value);
 }
Пример #30
0
 public function renderContent()
 {
     $model = Cms::model()->findAllByAttributes(array('status' => 1, 'show_in_menu' => 1));
     //$model = Cms::model()->findAll();
     $this->render('navmenu', array('models' => $model, 'idul' => $this->idul, 'classli' => $this->classli, 'before_link' => $this->before_link, 'after_link' => $this->after_link, 'before_content' => $this->before_content, 'after_content' => $this->after_content));
 }