Ejemplo n.º 1
0
 protected function renderContent()
 {
     $criteria = new CDbCriteria();
     $criteria->addCondition('status=1');
     $criteria->order = 'create_time DESC';
     $criteria->limit = 20;
     $hopam = Hopam::model()->findAll($criteria);
     /*$dataProvider = new CActiveDataProvider('Song', array(
           'pagination' => array(
               'pageSize' => Yii::app()->params['postsPerPage'],
           ),
           'criteria' => $criteria,
       ));
       $this->render('newest_song',array('songs'=>$dataProvider));*/
     echo CHtml::openTag("div", array('class' => 'title'));
     echo "Hợp Âm Mới";
     echo CHtml::closeTag("div");
     if ($hopam) {
         echo CHtml::openTag("ul");
         foreach ($hopam as $hp) {
             echo CHtml::openTag('li');
             echo CHtml::link($hp->title, array('/hopam/view', 'id' => $hp->id, "title" => Lnt::safeTitle($hp->title))) . " <span style='color:#a7a7a7'>({$hp->view})</span>";
             echo CHtml::closeTag('li');
         }
         echo CHtml::closeTag("ul");
     }
 }
Ejemplo n.º 2
0
 public function actionView()
 {
     $this->layout = 'hopam_detail';
     $hopam = Hopam::model()->findByPk($_GET['id']);
     $hopam->view += 1;
     $hopam->update(array('view'));
     $comment = $this->newComment($hopam);
     $cs = Yii::app()->getClientScript();
     $js = $this->generateJs();
     $cs->registerScript('sharebox', $js, CClientScript::POS_READY);
     //        $assetsUrl = $this->getAssetsUrl();
     $assetsUrl = '/js/transposer';
     $cs->registerCssFile($assetsUrl . '/jquery.transposer.css', 'screen');
     $cs->registerCoreScript('jquery');
     $cs->registerScriptFile($assetsUrl . '/jquery-ui.js');
     $cs->registerScriptFile($assetsUrl . '/jquery.ui.touch-punch.js');
     $cs->registerScriptFile($assetsUrl . '/jquery_chords.js');
     $cs->registerScriptFile($assetsUrl . '/jquery.transposer.js');
     $xmlFile = Yii::getPathOfAlias('webroot') . $hopam->lyrics;
     //var_dump($xmlFile);
     $xml = simplexml_load_file($xmlFile);
     $dataRows = $xml->DataRows->DataRow;
     $lyrics = array();
     $pattern = array("+", "|");
     foreach ($dataRows as $row) {
         $row = preg_replace("/\\+/i", "", (string) $row);
         //            $row = preg_replace("/\|/i","",(string)$row);
         $lyrics[] = $row;
     }
     $chords = $xml->Transposes->Transpose->Keys->Key->Chords->Chord;
     $key = (string) $xml->Transposes->Transpose->Keys->Key->Name;
     $key = substr($key, 0, strpos($key, " "));
     $chordList = array();
     foreach ($chords as $chord) {
         $apps = $chord->Apps->App;
         foreach ($apps as $app) {
             $ch = $app->Chord;
             $chordList[strtolower($ch)] = preg_replace('/\\//', "Slash", $ch);
             $id = $app->AppID;
             $locs = $app->Locs->Loc;
             foreach ($locs as $loc) {
                 //                var_dump((string)$loc->Row);die;
                 $row = (string) $loc->Row;
                 $col = (string) $loc->Col;
                 $line = CHtml::encode($lyrics[$row]);
                 $arrLine = explode(" ", $line);
                 if ($id > 1) {
                     // && !preg_match('/\//',$ch)
                     $arrLine[$col] = "[" . $ch . "." . $id . "]" . $arrLine[$col];
                 } else {
                     $arrLine[$col] = "[" . $ch . "]" . $arrLine[$col];
                 }
                 $lyrics[$row] = implode(" ", $arrLine);
             }
         }
     }
     $hopam->lyrics = implode("\n", $lyrics);
     //        var_dump($hopam->lyrics);die;
     $this->render('view', array('hopam' => $hopam, 'chord_list' => $chordList, 'comment' => $comment, 'key' => $key));
 }
Ejemplo n.º 3
0
 public function actionAdmin()
 {
     $model = new Hopam('search');
     $model->unsetAttributes();
     if (isset($_GET['Hopam'])) {
         $model->setAttributes($_GET['Hopam']);
     }
     $this->render('admin', array('model' => $model));
 }
Ejemplo n.º 4
0
<?php

$this->breadcrumbs = array(Hopam::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . Hopam::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . Hopam::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(Hopam::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));