Example #1
0
 /**
  * Test alias generator
  *
  * @dataProvider provideTitleAlias
  */
 public function testSetAliasFromTitle($title, $alias)
 {
     $page = new Default_Model_Page();
     $page->setTitle($title);
     $page->setAliasFromTitle();
     $this->assertEquals($alias, $page->getAlias());
 }
Example #2
0
 public function page($key = null, $field = 'message')
 {
     $model = new Default_Model_Page();
     $f = $field == 'description' ? 'message' : $field;
     $data = $model->fetchCard($key);
     $data_valid = $this->view->override()->overrideSingle($data, 'page');
     return $field == 'all' ? $data_valid : $data_valid->{$field};
 }
 function indexAction()
 {
     $muser = new Default_Model_Page();
     $conten = $muser->page_1();
     $qc = $muser->list_page(52);
     $this->view->list = $conten;
     $this->view->qc = $qc;
     $side = $muser->list_side_home();
     $this->view->side = $side;
 }
Example #4
0
 public function Search()
 {
     $view = new Zend_View();
     $base = $view->baseUrl();
     // echo"<script type=\"text/javascript\" src=\"$base/js/AJAX_2.js\"></script>";
     echo "<link href=\"{$base}/css/bootstrap-cerulean_1.css\" media=\"screen\" rel=\"stylesheet\" type=\"text/css\" >\n";
     echo "<form action=\"{$base}/product/search\" method=\"get\" enctype=\"multipart/form-data\" name=\"tt_mh\" id=\"tt_mh\"  class=\"form-horizontal\">\n <div class=\"control-group\" style='margin-left:-30px'>\n        <label class=\"control-label\" for=\"selectError\">Tìm kiếm</label>\n        <div class=\"controls\">\n            <input name=\"title\" type=\"text\" class=\"span6 typeahead\" id=\"typeahead\"  data-provide=\"typeahead\"  style=\"float: left; margin-right: 10px; width: 250px\" >\n            \n           ";
     $page = new Default_Model_Page();
     $page->list_category();
     echo "   <script>\n            \$(document).ready(function(  ){\n                \$(\"select option:selected\").each(function () {\n                    \$(\"div#div123\").get(\"{$base}/default/register/menu?id=\" + \$(this).val());\n                });\t\n            });\n\t\n            \$(\"select#category_id\").change(function () {\n                var str = \"\";\n                \$(\"select option:selected\").each(function () {\n                    str += \$(this).val() + \" \";\n                });\n               \n            })\n            .change(function(  ){\n                \$(\"div#div123\").load(\"{$base}/default/register/menu?id=\" + \$(this).val());\n            });\n        </script> ";
     echo "\n        <div id=\"div123\" style=\"float: left; margin: 2px 10px 0px 0px\">\n                <select name=\"\">\n                    <option>--- Chọn menu ---</option>\n                </select>\n            </div>\n            <div id=\"div2\" style=\"float: left;margin: 2px 10px 0px 0px\"></div>\n            <button type=\"submit\" class=\"btn btn-primary\" style=\"margin-top: 2px\">Search</button>\n        </div>\n    </div>\n            \n\n   \n                 \n               \n   \n</form>\n     \n";
 }
Example #5
0
 public function hotline()
 {
     $url = new Zend_View();
     $url = $url->baseUrl();
     $page = new Default_Model_Page();
     $hot = $page->page_3(9);
     $down = $page->page_3(13);
     echo " <div class=\"heed\"> ";
     foreach ($hot as $val) {
         echo "<div class=\"heed_1\">{$val['content']}</div>  ";
     }
     echo " <div class=\"heed_2\">";
     foreach ($down as $val) {
         echo "      <div class=\"heed_2_1\" >{$val['content']}  </div>";
     }
     echo "<div class=\"heed_2_2\" >\n                <a href=\"javascript:void(0)\">  <img src=\"{$url}/template/images/face_03.jpg\" ></a>\n                <a href=\"javascript:void(0)\">   <img src=\"{$url}/template/images/g+_03.jpg\" > </a>\n                <a href=\"javascript:void(0)\">   <img src=\"{$url}/template/images/tw_03.jpg\" > </a>\n                <a href=\"javascript:void(0)\">   <img src=\"{$url}/template/images/youtube_03.jpg\" > </a>\n                <a href=\"javascript:void(0)\">   <img src=\"{$url}/template/images/zing_03.jpg\" > </a>\n            </div>\n        </div>\n    </div> ";
 }
 public function partnerAction()
 {
     $sys = new Default_Model_Page();
     $this->view->list = $sys->list_cus();
 }
Example #7
0
 public function testSave()
 {
     $request = array('title' => 'foo', 'content' => 'some content', 'language' => 'bar');
     $model = new Default_Model_Page($request);
     $model->setAliasFromTitle();
     $form = $this->getMock('Zend_Form', array('isValid', 'getValues'));
     $form->expects($this->once())->method('isValid')->will($this->returnValue(true));
     $form->expects($this->once())->method('getValues')->will($this->returnValue($request));
     $mapper = $this->getMock('Mapper', array('save'));
     $mapper->expects($this->once())->method('save')->with($model);
     $service = new Default_Service_Page();
     $service->setForm($form);
     $service->setMapper($mapper);
     $service->save($request);
 }
 public function customerAction()
 {
     $system = new Default_Model_Page();
     $list_3 = $system->list_cus();
     $this->view->list = $list_3;
 }
Example #9
0
 function configAction()
 {
     $model = new Default_Model_Page();
     $o = $model->getAdapter()->getConfig();
 }
Example #10
0
 function suppor_online()
 {
     echo " <div class=\"title1\">\n        <div style=\"padding-top:10px;\" align=\"center\">Tư Vấn Bán Hàng</div>\n        </div>\n        <div class=\"hotro\" align=\"center\">";
     $page = new Default_Model_Page();
     $hotline = $page->page_3(57);
     foreach ($hotline as $value) {
         echo $value['content'];
     }
     echo "<div style=\"clear:both; height:5px;\"></div>\n</div>";
 }
Example #11
0
 public function partners()
 {
     $side = new Default_Model_Page();
     $side->partners();
 }
Example #12
0
 function tab_2()
 {
     $page = new Default_Model_Page();
     $vie = new Zend_View();
     $base = $vie->baseurl();
     echo "\n        \n\n\n<ul id=\"countrytabs1\" class=\"shadetabs\">\n<li><a href=\"#\" rel=\"country3\" class=\"selected\">Tin Hot Nhất</a></li>\n<li><a href=\"#\" rel=\"country4\">Tin Khuyến Mãi </a></li>\n\n</ul>\n\n<div style=\"border:1px solid gray; width:218px; margin-bottom: 1em; \">\n\n<div id=\"country3\" class=\"tabcontent\">";
     $page->top_hot();
     echo "</div>\n\n<div id=\"country4\" class=\"tabcontent\">";
     $page->top_km();
     echo "</div>\n\n\n\n</div>\n\n<script type=\"text/javascript\">\n\nvar countries=new ddtabcontent(\"countrytabs1\")\ncountries.setpersist(true)\ncountries.setselectedClassTarget(\"link\") \ncountries.init()\n\n</script>";
 }
 function detailproductAction()
 {
     $muser = new Default_Model_Page();
     $id = $this->_request->getParam('id');
     $pro = $muser->list_detail_products($id);
     $this->view->book = $pro;
     $new = $muser->list_Products_New();
     $this->view->bookk = $new;
     // Zend_Registry::getInstance();
     //  echo  $value = Zend_Registry::get('memberss');
     $session = new Zend_Session_Namespace('members');
     $username = $session->members;
     $member = $muser->detail_member($username);
     $this->view->members = $member;
 }
Example #14
0
 public function sildeshow()
 {
     $side = new Default_Model_Page();
     $side->page_sildeshow();
 }
Example #15
0
 /**
  * Persists the given model on the backend.
  *
  * Creates a language dir if not presented, and writes a file into it.
  * Filename is the page alias.
  *
  * @param Default_Model_Page $page Page model to save
  * @return bool true
  * @throws Light_Exception_InvalidParameter
  * If language or alias not presented in the model
  */
 public function save(Default_Model_Page $page)
 {
     if ("" == $page->getLanguage()) {
         require_once 'Light/Exception/InvalidParameter.php';
         throw new Light_Exception_InvalidParameter("Language not provided");
     }
     if ("" == $page->getAlias()) {
         require_once 'Light/Exception/InvalidParameter.php';
         throw new Light_Exception_InvalidParameter("Alias not provided");
     }
     $fileUri = $this->getDirectoryRoot() . DIRECTORY_SEPARATOR . $page->getLanguage() . DIRECTORY_SEPARATOR . $page->getAlias();
     $fileContent = $this->_contentFromTitleAndContent($page->getTitle(), $page->getContent());
     $this->_createDirIfNeeded($page->getLanguage());
     file_put_contents($fileUri, $fileContent);
     return true;
 }
Example #16
0
 /**
  * Save method needs language field
  *
  * @expectedException Light_Exception_InvalidParameter
  */
 public function testSaveNoLanguage()
 {
     $model = new Default_Model_Page();
     //set language explicitly to avoid catch exception by no alias
     $model->setAlias('bar');
     $mapper = new Default_Model_PageFileMapper();
     $mapper->save($model);
 }
 public function commentAction()
 {
     $auth = Zend_Auth::getInstance();
     if (!$auth->hasIdentity()) {
         $full_name = "";
     } else {
         $infoUser = $auth->getIdentity();
         $full_name = $infoUser->full_name;
     }
     $system = new Default_Model_Page();
     $this->view->purifier = Zend_Registry::get('purifier');
     $conf = HTMLPurifier_Config::createDefault();
     $purifier = new HTMLPurifier($conf);
     $comment_id = $purifier->purify($this->_request->getParam('comment_id'));
     if (empty($comment_id)) {
         $comment_id = 0;
     }
     $link = $purifier->purify($this->_request->getParam('link'));
     $data = array("comment" => $purifier->purify($this->_request->getParam('content')), "email" => $purifier->purify($this->_request->getParam('email')), "full_name" => $purifier->purify($this->_request->getParam('full_name')), "page_id" => $purifier->purify($this->_request->getParam('id')), "user_name" => $full_name, "date_create" => time(), "child_comment_id" => $comment_id);
     echo $system->save_commnent($data, $link);
     die;
 }
 function productAction()
 {
     $muser = new Default_Model_Page();
     $id = $this->_request->getUserParam('id');
     $paginator = Zend_Paginator::factory($muser->list_Products_());
     //Số user trên một trang
     $paginator->setItemCountPerPage(12);
     //Số trang được hiện ra để click
     $paginator->setPageRange(5);
     //Lấy trang hiện tại
     $currentPage = $this->_request->getParam('page', 1);
     $paginator->setCurrentPageNumber($currentPage);
     //Truyền dữ liệu ra view
     $this->view->book = $paginator;
     $title = $muser->list_Products_title($id);
     $this->view->books = $title;
     $pr = new Default_Model_Product();
     $mlist = $pr->list_menu();
     if (!empty($mlist)) {
         foreach ($mlist as $index => $val) {
             $mlist[$index]['product'] = $pr->list_products_home($val['id']);
         }
     }
     //$mlist=  $this->_format_showlist($mlist);
     //                    echo "<pre>";
     //                        print_r($mlist);
     //                    echo "</pre>";
     //                   die;
     $this->view->list = $mlist;
 }
Example #19
0
    public function insertControl($data)
    {
        $ok = true;
        $name = ucfirst($data['parentid']);
        $model = new Zend_CodeGenerator_Php_Class();
        $model->setName('Default_Model_' . $name);
        if ($data['parent']) {
            $model->setExtendedClass($data['parent']);
        }
        $prop = array();
        if ($data['table']) {
            $prop[] = array('name' => '_name', 'visibility' => 'protected', 'defaultValue' => trim($data['table']));
        }
        if ($data['multilang']) {
            $ml = explode(',', str_replace(array(' '), array(''), trim($data['multilang'])));
            $prop[] = array('name' => '_multilang_field', 'visibility' => 'protected', 'defaultValue' => $ml);
        }
        if ($prop) {
            $model->setProperties($prop);
        }
        if ($data['method']) {
            $met = array();
            foreach ($data['method'] as $el) {
                $mn = $mb = '';
                $mp = array();
                switch ($el) {
                    case 'list':
                        $mn = 'fetchList';
                        $mb = 'return $this->fetchAll();';
                        break;
                    case 'list_join':
                        $mn = 'fetchList';
                        $mb = '$m = new Default_Model_Temp();
$s = $this->getAdapter()->select()
	->from(array(\'i\' => $this->info(\'name\')))
	->join(array(\'m\' => $m->info(\'name\')), \'i.parentid = m.id\', array(
		\'temp\' => \'o.title\'
	))
	->group(\'i.id\')
	->order(\'i.orderid\');
return $this->fetchAll($s);';
                        break;
                    case 'card':
                        $mn = 'fetchCard';
                        $mp = array(array('name' => 'id'));
                        $mb = 'return $this->fetchRow(array(\'`stitle` = ?\' => $id));';
                        break;
                    case 'card_join':
                        $mn = 'fetchCard';
                        $mp = array(array('name' => 'id'));
                        $mb = '$m = new Default_Model_Temp();
$s = $this->getAdapter()->select()
	->from(array(\'i\' => $this->info(\'name\')))
	->join(array(\'m\' => $m->info(\'name\')), \'i.parentid = m.id\', array(
		\'temp\' => \'o.title\'
	))
	->group(\'i.id\')
	->where(\'`stitle` = ?\', $id);
return $this->fetchRow($s);';
                        break;
                    case 'idtitle':
                        $mn = 'fetchIdTitle';
                        $mb = 'return $this->fetchPairs(\'id\', \'title\', null, \'orderid\');';
                        break;
                }
                if ($mn) {
                    $met[] = array('name' => $mn, 'body' => $mb, 'parameters' => $mp);
                }
            }
            if ($met) {
                $model->setMethods($met);
            }
        }
        $c = '<?php' . "\n\n" . $model->generate();
        $ok = file_put_contents(APPLICATION_PATH . '/models/' . $name . '.php', $c);
        if ($ok) {
            @chmod(APPLICATION_PATH . '/models/' . $name . '.php', 0777);
        }
        if ($data['table'] && $data['table_create']) {
            $n = substr($data['table_create'], 3);
            $model = new Default_Model_Page();
            switch (substr($data['table_create'], 0, 3)) {
                case '_e_':
                    $model->getAdapter()->query('CREATE TABLE `' . $data['table'] . '` LIKE `' . $n . '`');
                    break;
                case '_t_':
                    $c = file_get_contents(APPLICATION_PATH . '/../library/Zkernel/Other/Template/Db/' . $n);
                    if ($c) {
                        $c = str_replace(array('%name%'), array($data['table']), $c);
                        $model->getAdapter()->query($c);
                    }
                    break;
            }
        }
        return $ok;
    }