Example #1
0
 function Page()
 {
     parent::BasePage();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents();
     $menu = new Menu();
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category();
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
 public function getContentDeliveryTypesById($request)
 {
     $json = json_encode($request->parameters);
     $contents = new Contents();
     $jsonObj = json_decode($json);
     $jsonMessage = $contents->validateJsonForContentMetadata($jsonObj);
     if ($jsonMessage != Message::SUCCESS) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => $jsonMessage);
         $this->outputError($response);
         return;
     }
     if (!$contents->setValuesFromJsonObj($jsonObj)) {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_INVAID_REQUEST_BODY);
         $this->outputError($response);
         return;
     }
     if (trim($contents->cm_id) == '') {
         $response = array("status" => "ERROR", "status_code" => '400', 'msgs' => Message::ERROR_BLANK_CMD_ID);
         $this->outputError($response);
         return;
     }
     $contentMetaDataObj = $contents->getContentDeliveryTypesById($contents->cf_cm_id);
     if (!empty($contentMetaDataObj)) {
         $response = array("status" => "SUCCESS-BUSINESS", "status_code" => '200', 'contentDeliveryType' => $contentMetaDataObj);
         $this->outputSuccess($response);
         return;
     } else {
         $response = array("status" => "ERROR-BUSINESS", "status_code" => '404', 'msgs' => 'No content metadata information available !.');
         $this->outputError($response);
         return;
     }
 }
 public function arDeleteModelAction($id)
 {
     $content = new Contents($id);
     if (!empty($content)) {
         $content->destroy();
     }
     redirect('active-record/active-record');
 }
Example #4
0
 public function __construct()
 {
     parent::__construct();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents(['Settings' => $this->settings]);
     $menu = new Menu($this->settings);
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category(['Settings' => $content->pdo]);
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     // Add in system types to console categories to make the boot strap drop down list less long.
     $consoleCatList = array();
     foreach ($parentcatlist as $parent) {
         if ($parent['title'] === 'Console') {
             foreach ($parent['subcatlist'] as $consoleCat) {
                 if (preg_match('/^XBOX/i', $consoleCat['title'])) {
                     $consoleCatList['Microsoft'][] = $consoleCat;
                 } else {
                     if (preg_match('/^([3N]DS|N?GC)$|^WII/i', $consoleCat['title'])) {
                         $consoleCatList['Nintendo'][] = $consoleCat;
                     } else {
                         if (preg_match('/PS[\\dXP ]/i', $consoleCat['title'])) {
                             $consoleCatList['Sony'][] = $consoleCat;
                         } else {
                             $consoleCatList['Other'][] = $consoleCat;
                         }
                     }
                 }
             }
             break;
         }
     }
     $this->smarty->assign('consolecatlist', $consoleCatList);
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     } else {
         $this->smarty->assign('header_menu_cat', '');
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
 public function save()
 {
     if ($this->perm->can_create == 'y') {
         $data = new Contents();
         $data->from_array($_POST);
         $data->save();
         save_logs($this->menu_id, 'Update', $data->id, ' Update Footage Contact  ');
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
 public function getMaxVOId()
 {
     $contents = new Contents();
     $maxVOID = $contents->getMaxVOId();
     if (!empty($maxVOID)) {
         //$contentHistoryDetails = $contentDownloadHistory->getContentDetailsByCatelogDetailIdsAndContentMetadataIds( $cdIds, $cmdIds );
         $response = array("status" => "SUCCESS-BUSINESS", "status_code" => '200', 'maxVOID' => $maxVOID);
         $this->outputSuccess($response);
         return;
     } else {
         $response = array("status" => "ERROR-BUSINESS", "status_code" => '404', 'msgs' => 'No data available !.');
         $this->outputError($response);
         return;
     }
 }
 public function save()
 {
     if ($this->perm->can_create == 'y') {
         $data = new Contents();
         if ($_POST['id'] == '') {
             $_POST['created_by'] = $this->current_user->id;
         } else {
             $_POST['updated_by'] = $this->current_user->id;
         }
         $data->from_array($_POST);
         $data->save();
         save_logs($this->menu_id, 'Update', $this->session->userdata("id"), ' Update ASEAN Declaration ');
     }
     redirect($_SERVER['HTTP_REFERER']);
 }
Example #8
0
 public function handleRequest($reqId, $reqSubId)
 {
     $output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
     switch ($reqId) {
         case "gallery":
             $photosPath = "gallery/{$reqSubId}";
             $listOfPhotos = $this->ioResource->getPhotosOfGallery($reqSubId);
             $output .= "<photos>\n";
             foreach ($listOfPhotos as $photo) {
                 $output .= "  <photo>{$photosPath}/{$photo}</photo>\n";
             }
             $output .= "</photos>\n";
             break;
         case "news":
             $output .= "<news>\n";
             $rawContents = $this->ioResource->getRawContents("news");
             foreach ($rawContents->unit as $thisItem) {
                 $output .= "  <item>\n";
                 $output .= "    <title><![CDATA[" . parent::lightCooking($thisItem->title) . "]]></title>\n";
                 $output .= "    <time><![CDATA[" . parent::lightCooking($thisItem->time) . "]]></time>\n";
                 $output .= "    <cathegory><![CDATA[" . parent::lightCooking($thisItem->cathegory) . "]]></cathegory>\n";
                 $output .= "    <description><![CDATA[" . parent::lightCooking($thisItem->description) . "]]></description>\n";
                 $output .= "  </item>\n";
             }
             $output .= "</news>\n";
             break;
     }
     return $output;
 }
Example #9
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 the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Contents::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #10
0
 public static function get($url)
 {
     /** @var Contents $content */
     $content = Contents::findFirst(['url = :url: AND type = :type:', 'bind' => ['url' => $url, 'type' => Urls::CONTENT], 'order' => 'created_at ASC']);
     if (!$content) {
         return ['success' => false];
     }
     /** @var Contents $common */
     $common = Contents::findFirst(['url = :url: AND type = :type:', 'bind' => ['url' => ' ', 'type' => Urls::COMMON], 'order' => 'created_at ASC']);
     return json_decode($content->content, true) + json_decode($common->content, true);
 }
Example #11
0
 /**
  * Default constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $role = Users::ROLE_GUEST;
     if ($this->userdata != null) {
         $role = $this->userdata["role"];
     }
     $content = new Contents(['Settings' => $this->settings]);
     $f = new Forum();
     $menu = new Menu($this->settings);
     $this->smarty->assign('menulist', $menu->get($role, $this->serverurl));
     $this->smarty->assign('usefulcontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role));
     $this->smarty->assign('articlecontentlist', $content->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role));
     if ($this->userdata != null) {
         $this->smarty->assign('recentforumpostslist', $f->getRecentPosts($this->settings->getSetting('showrecentforumposts')));
     }
     $this->smarty->assign('main_menu', $this->smarty->fetch('mainmenu.tpl'));
     $this->smarty->assign('useful_menu', $this->smarty->fetch('usefullinksmenu.tpl'));
     $this->smarty->assign('article_menu', $this->smarty->fetch('articlesmenu.tpl'));
     $category = new Category(['Settings' => $content->pdo]);
     if ($this->userdata != null) {
         $parentcatlist = $category->getForMenu($this->userdata["categoryexclusions"]);
     } else {
         $parentcatlist = $category->getForMenu();
     }
     $this->smarty->assign('parentcatlist', $parentcatlist);
     $searchStr = '';
     if ($this->page == 'search' && isset($_REQUEST["id"])) {
         $searchStr = (string) $_REQUEST["id"];
     }
     $this->smarty->assign('header_menu_search', $searchStr);
     if (isset($_REQUEST["t"])) {
         $this->smarty->assign('header_menu_cat', $_REQUEST["t"]);
     } else {
         $this->smarty->assign('header_menu_cat', '');
     }
     $header_menu = $this->smarty->fetch('headermenu.tpl');
     $this->smarty->assign('header_menu', $header_menu);
 }
 /** Completely cooks the body, applying every sort of transformation.
  */
 protected function bodyCook()
 {
     /* Applyies first simple cooking */
     $this->bodyCooked = parent::lightCooking($this->body->contents);
     /* Applyies bbcode formatting */
     $this->bodyCooked = parent::bbCodeCooking($this->bodyCooked);
     /* For every image it checks in the body if it's called and substitutes it. */
     if (is_array($this->images)) {
         for ($count = 0; $count <= max(array_keys($this->images)); $count++) {
             $isInTemplate = $this->images[$count]->template == "true";
             $needsHover = $this->images[$count]->hover == "true";
             $imageSrc = $isInTemplate ? $this->template : "";
             $imageSrc .= $this->images[$count]->src;
             if ($needsHover) {
                 $this->theHover->addHoveredImage($imageSrc, str_replace("normal", "hover", $imageSrc), "img{$count}");
             }
             $this->bodyCooked = str_replace("[img id={$count}]", "<img id=\"img{$count}\" alt=\"img{$count}\" src=\"{$imageSrc}" . "\" style=\"" . $this->images[$count]->style . '" ' . ($needsHover ? "onmouseover=\"mouseOver('img{$count}')\"" . " onmouseout=\"mouseOut('img{$count}')\"" : "") . " />", $this->bodyCooked);
         }
     }
 }
Example #13
0
<?php

$te = $page->smarty;
$arPages = array();
$arPages[] = buildURL("Home", "Home Page", "/", 'daily', '1.0');
$role = 0;
if ($page->userdata != null) {
    $role = $page->userdata["role"];
}
//
// useful links
//
$contents = new Contents();
$contentlist = $contents->getForMenuByTypeAndRole(Contents::TYPEUSEFUL, $role);
foreach ($contentlist as $content) {
    $arPages[] = buildURL("Useful Links", $content["title"], '/content/' . $content["id"] . $content["url"], 'monthly', '0.50');
}
//
// articles
//
$contentlist = $contents->getForMenuByTypeAndRole(Contents::TYPEARTICLE, $role);
foreach ($contentlist as $content) {
    $arPages[] = buildURL("Articles", $content["title"], '/content/' . $content["id"] . $content["url"], 'monthly', '0.50');
}
//
// static pages
//
$arPages[] = buildURL("Useful Links", "Contact Us", "/contact-us", 'yearly', '0.30');
$arPages[] = buildURL("Useful Links", "Site Map", "/sitemap", 'weekly', '0.50');
if ($page->userdata != null) {
    $arPages[] = buildURL("Useful Links", "Rss Feeds", "/rss", 'weekly', '0.50');
Example #14
0
</div> <!-- END CONTENT -->
</div> <!-- END SUPER -->
<div class="footer-wrap">
	<!-- BEGIN PRE-FOOTER -->
    <div class="pre-footer">
		<div class="container">
			<div class="row">
			<?php 
Yii::import('application.modules.admin.modules.content.models.Contents');
Yii::import('application.modules.admin.modules.content.models.ContentsLang');
$criteria = new CDbCriteria(array('condition' => 'name = :name', 'params' => array('name' => 'Контакты футер'), 'with' => array('lang')));
$content = Contents::model()->find($criteria);
$text = '';
if (!empty($content) && !empty($content->lang)) {
    $text = $content->lang->text;
}
echo $text;
?>
			</div>
		</div>
    </div>
    <!-- END PRE-FOOTER -->
	<!-- BEGIN FOOTER -->
	<div class="footer">
		<div class="container">
			<div class="row">
				<!-- BEGIN COPYRIGHT -->
				<div class="col-md-6 col-sm-6 padding-top-10">
					<?php 
echo date('Y');
?>
Example #15
0
<?php

require_once "config.php";
require_once WWW_DIR . "/lib/adminpage.php";
require_once WWW_DIR . "/lib/content.php";
$page = new AdminPage();
$contents = new Contents();
$contentlist = $contents->getAll();
$page->smarty->assign('contentlist', $contentlist);
$page->title = "Content List";
$page->content = $page->smarty->fetch('content-list.tpl');
$page->render();
<?php

require_once "config.php";
require_once WWW_DIR . "/lib/content.php";
require_once WWW_DIR . "/lib/adminpage.php";
$page = new AdminPage();
if (isset($_GET['id'])) {
    $contents = new Contents();
    $contents->delete($_GET['id']);
}
$referrer = $_SERVER['HTTP_REFERER'];
header("Location: " . $referrer);
Example #17
0
 /**
  * @param $params
  */
 function parse_page($params)
 {
     /** init tingkat yang ada di params */
     $this->init_tingkat($params);
     $view_path = LRS_VIEW_ABS_PATH;
     $file_to_include = $view_path . DS . self::page_404;
     /** kondisi untuk halaman publik utama atau beranda */
     if (!$this->has_tingkat(1) || $this->get_tingkat(1) == self::view_beranda) {
         $file_to_include = $view_path . DS . self::page_index;
         /** untuk kondisi pertama, tentukan jenis nya terlebih dahulu */
     } else {
         $has_view = true;
         /** untuk tingkat 1 dari jenis view, langsung tampilkan index */
         switch ($this->get_tingkat(1)) {
             case self::view_admin:
                 Contents::get_instance()->set_view(self::view_admin);
                 break;
             case self::view_staff:
                 Contents::get_instance()->set_view(self::view_staff);
                 break;
             default:
                 $has_view = false;
         }
         /** jika kondisi diatas memenuhi diantara view yang telah ditentukan */
         if ($has_view) {
             /**
              * kondisi pertama jika memang yang diinginkan adalah halaman
              * index dari tiap view
              */
             $condition1 = Contents::get_instance()->get_view_path() . DS . self::page_index;
             /**
              * kondisi kedua jika sub page dari tiap view tidak ketemu
              * gunakan index dari tiap view
              */
             $condition2 = Contents::get_instance()->get_view_path() . DS . (!$this->has_tingkat(2) ? self::page_index : $this->get_tingkat(2) . self::script_ext);
             /**
              * lakukan pengecekan
              */
             $file_to_include = is_readable($condition2) ? $condition2 : $condition1;
             /** jika memang tidak ada di daftar view */
         } else {
             /**
              * coba eksekusi tingkat1.php jika ada
              */
             $file_to_include = $view_path . DS . $this->get_tingkat(1) . self::script_ext;
             /**
              * dan apabila memang tidak ada, langsung berikan halaman 404
              */
             is_readable($file_to_include) || ($file_to_include = $view_path . DS . self::page_404);
             /**
              * jika memang file untuk di-include tidak ditemukan
              * bersihkan variabel view yang sudah kedung tersimpan
              * di objek Contents
              */
             Contents::get_instance()->remove_view();
         }
     }
     //lrs_exit( $file_to_include );
     /** mulai meng-include */
     if (is_readable($file_to_include)) {
         include $file_to_include;
     } else {
         lrs_exit('Script yang side eksekusi belum ada.', 'alert');
     }
 }
Example #18
0
<?php

require_once "config.php";
require_once WWW_DIR . "/lib/content.php";
$contents = new Contents();
$role = 0;
if ($page->userdata != null) {
    $role = $page->userdata["role"];
}
$contentid = 0;
if (isset($_GET["id"])) {
    $contentid = $_GET["id"];
}
if ($contentid == 0) {
    $content = $contents->getIndex();
} else {
    $content = $contents->getByID($contentid, $role);
}
if ($content == null) {
    $page->show404();
}
$page->smarty->assign('content', $content);
$page->meta_title = $content->title;
$page->meta_keywords = $content->metakeywords;
$page->meta_description = $content->metadescription;
$page->content = $page->smarty->fetch('content.tpl');
$page->render();
Example #19
0
<?php

require_once './config.php';
$contents = new Contents(['Settings' => $page->settings]);
$role = 0;
if ($page->userdata != null) {
    $role = $page->userdata["role"];
}
$contentid = 0;
if (isset($_GET["id"])) {
    $contentid = $_GET["id"];
}
$request = false;
if (isset($_REQUEST['page'])) {
    $request = $_REQUEST['page'];
}
if ($contentid == 0 && $request == 'content') {
    $content = $contents->getAllButFront();
    $page->smarty->assign('front', false);
    $page->meta_title = 'Contents page';
    $page->meta_keywords = 'contents';
    $page->meta_description = 'This is the contents page.';
} else {
    if ($contentid != 0 && $request !== false) {
        $content = array($contents->getByID($contentid, $role));
        $page->smarty->assign('front', false);
        $page->meta_title = 'Contents page';
        $page->meta_keywords = 'contents';
        $page->meta_description = 'This is the contents page.';
    } else {
        $content = $contents->getFrontPage();
Example #20
0
 /**
  * 重载select
  *
  * @access public
  * @return void
  */
 public function select()
 {
     if ($this->_feed) {
         // 对feed输出加入限制条件
         return parent::select()->where('table.contents.allowFeed = ?', 1)->where('table.contents.password IS NULL');
     } else {
         return parent::select();
     }
 }
Example #21
0
<?php

require_once "config.php";
require_once WWW_DIR . "/lib/adminpage.php";
require_once WWW_DIR . "/lib/content.php";
$page = new AdminPage();
$contents = new Contents();
$id = 0;
// set the current action
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'view';
switch ($action) {
    case 'add':
        $page->title = "Content Add";
        $content = new Content();
        $content->showinmenu = "1";
        $content->status = "1";
        $content->contenttype = "2";
        $page->smarty->assign('content', $content);
        break;
    case 'submit':
        //
        // validate and add or update
        //
        $returnid = 0;
        if (!isset($_POST["id"]) || $_POST["id"] == "") {
            $returnid = $contents->add($_POST);
        } else {
            $content = $contents->update($_POST);
            $returnid = $content->id;
        }
        header("Location:content-add.php?id=" . $returnid);
Example #22
0
 public function actionDeleteContent($id)
 {
     if (Yii::app()->request->isPostRequest) {
         if (isset($_POST['YII_CSRF_TOKEN']) && $_POST['YII_CSRF_TOKEN'] === Yii::app()->request->csrfToken) {
             $model = Contents::model()->findByPk($id);
             $page_id = $model->page_id;
             $transaction = Yii::app()->db->beginTransaction();
             try {
                 if (!$model->delete()) {
                     throw new Exception('Ошибка при сохранении данных.');
                 }
                 $criteria = new CDbCriteria();
                 $criteria->condition = 'content_id=:content_id';
                 $criteria->params = array('content_id' => $id);
                 $builder = new CDbCommandBuilder(Yii::app()->db->getSchema());
                 $command = $builder->createDeleteCommand('contents_lang', $criteria);
                 if ($command->execute() === false) {
                     throw new Exception('Ошибка при сохранении данных.');
                 }
                 $transaction->commit();
             } catch (Exception $e) {
                 $transaction->rollBack();
                 echo CJSON::encode(array('error' => $e->getMessage()));
                 Yii::app()->end();
             }
             $this->redirect($this->createUrl('pages/edit/id/' . $page_id));
         }
     } else {
         throw new CHttpException(400, 'Invalid request. Please do not repeat this request again.');
     }
 }