protected function setUp()
 {
     // Create a test file on the file system.
     $this->testFile = tempnam(TMP_FILES, 'SubmissionFile');
     // Mock a press
     import('classes.press.Press');
     $press = new Press();
     $press->setPrimaryLocale('en_US');
     $press->setPath('press-path');
     $press->setId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     // Mock a request
     $mockRequest = $this->getMock('PKPRequest', array('getContext'));
     $mockRequest->expects($this->any())->method('getContext')->will($this->returnValue($press));
     Registry::get('request', true, $mockRequest);
     // Register a mock monograph DAO.
     $monographDao = $this->getMock('MonographDAO', array('getById'));
     $monograph = new Monograph();
     $monograph->setId(SUBMISSION_FILE_DAO_TEST_SUBMISSION_ID);
     $monograph->setPressId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     $monographDao->expects($this->any())->method('getById')->will($this->returnValue($monograph));
     DAORegistry::registerDAO('MonographDAO', $monographDao);
     // Register a mock genre DAO.
     $genreDao = $this->getMock('GenreDAO', array('getById'));
     DAORegistry::registerDAO('GenreDAO', $genreDao);
     $genreDao->expects($this->any())->method('getById')->will($this->returnCallback(array($this, 'getTestGenre')));
     $this->_cleanFiles();
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
 }
 public function actionElement($param)
 {
     //Если параметр текст - это каталог, если число - элемент
     $paramArr = explode("/", $param);
     $paramArr = array_pop($paramArr);
     if (is_numeric($paramArr)) {
         //Число - это элемент
         $model = Press::model()->findByPk((int) $paramArr);
         if (empty($model)) {
             throw new CHttpException(404, 'The page can not be found.');
         }
         //Смотрим, нужно ли вставить фотогалерею
         $model->description = $this->addPhotogalery($model->description);
         $param = null;
         $render = 'view';
     } else {
         //Список новостей категории
         $paramArr = str_replace("press-", "", $paramArr);
         $model = array();
         //получаем новости в группах
         $model['group'] = PressGroup::model()->findAll(array("condition" => "status!=0", "order" => "id ASC"));
         $model_tmp = PressGroup::model()->find(array("condition" => "status!=0 AND url LIKE '" . $paramArr . "'", "order" => "id ASC"));
         //получаем новости без групп
         $model['first_group'] = Press::model()->findAll(array("condition" => "status!=0 AND group_id=" . $model_tmp->id, "order" => "id ASC"));
         $param = $model_tmp->id;
         $render = 'index';
     }
     if (empty($model)) {
         throw new CHttpException(404, 'The page can not be found.');
     }
     $this->render($render, array('model' => $model, 'param' => $param));
 }
 /**
  * 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 Press the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Press::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Beispiel #4
0
 /**
  * Internal function to return a Press object from a row.
  * @param $row array
  * @return Press
  */
 function &_returnPressFromRow(&$row)
 {
     $press = new Press();
     $press->setId($row['press_id']);
     $press->setPath($row['path']);
     $press->setSequence($row['seq']);
     $press->setEnabled($row['enabled']);
     $press->setPrimaryLocale($row['primary_locale']);
     HookRegistry::call('PressDAO::_returnPressFromRow', array(&$press, &$row));
     return $press;
 }
Beispiel #5
0
</h1>
        </div>
    </main>
    <div class="news-block">
        <main role="main" class="all">
            <div class="container news-all">
                <figure>
                    <?php 
if (!empty($model->image)) {
    echo '<img src="/uploads/filestorage/press/elements/small-' . $model->id . '.' . $model->image . '">';
}
?>
                </figure>
                <article>
                    <p><?php 
echo Press::model()->getDate($model->maindate);
?>
</p>
                    <blockquote>
                        <?php 
echo $model->name;
?>
                    </blockquote>
                        <?php 
echo $model->description;
?>
                </article>
            </div>
        </main>
    </div>
 /**
  * Save press settings.
  */
 function execute()
 {
     $pressDao =& DAORegistry::getDAO('PressDAO');
     if (isset($this->pressId)) {
         $press =& $pressDao->getPress($this->pressId);
     }
     if (!isset($press)) {
         $press = new Press();
     }
     $press->setPath($this->getData('path'));
     $press->setEnabled($this->getData('enabled'));
     if ($press->getId() != null) {
         $isNewPress = false;
         $pressDao->updatePress($press);
         $series = null;
     } else {
         $isNewPress = true;
         $site =& Request::getSite();
         // Give it a default primary locale
         $press->setPrimaryLocale($site->getPrimaryLocale());
         $pressId = $pressDao->insertPress($press);
         $pressDao->resequencePresses();
         // Make the file directories for the press
         import('lib.pkp.classes.file.FileManager');
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId);
         FileManager::mkdir(Config::getVar('files', 'files_dir') . '/presses/' . $pressId . '/monographs');
         FileManager::mkdir(Config::getVar('files', 'public_files_dir') . '/presses/' . $pressId);
         $installedLocales =& $site->getInstalledLocales();
         // Install default genres
         $genreDao =& DAORegistry::getDAO('GenreDAO');
         $genreDao->installDefaults($pressId, $installedLocales);
         /* @var $genreDao GenreDAO */
         // Install default publication formats
         $publicationFormatDao =& DAORegistry::getDAO('PublicationFormatDAO');
         /* @var $publicationFormatDao PublicationFormatDAO */
         $publicationFormatDao->installDefaults($pressId, $installedLocales);
         // Install default user groups
         $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
         $userGroupDao->installSettings($pressId, 'registry/userGroups.xml');
         // Make the site administrator the press manager of newly created presses
         $sessionManager =& SessionManager::getManager();
         $userSession =& $sessionManager->getUserSession();
         if ($userSession->getUserId() != null && $userSession->getUserId() != 0 && !empty($pressId)) {
             // get the default site admin user group
             $managerUserGroup =& $userGroupDao->getDefaultByRoleId($pressId, ROLE_ID_PRESS_MANAGER);
             $userGroupDao->assignUserToGroup($userSession->getUserId(), $managerUserGroup->getId());
         }
         // Install default press settings
         $pressSettingsDao =& DAORegistry::getDAO('PressSettingsDAO');
         $titles = $this->getData('title');
         Locale::requireComponents(array(LOCALE_COMPONENT_OMP_DEFAULT_SETTINGS));
         $pressSettingsDao->installSettings($pressId, 'registry/pressSettings.xml', array('indexUrl' => Request::getIndexUrl(), 'pressPath' => $this->getData('path'), 'primaryLocale' => $site->getPrimaryLocale(), 'pressName' => $titles[$site->getPrimaryLocale()]));
     }
     $press->updateSetting('name', $this->getData('name'), 'string', true);
     $press->updateSetting('description', $this->getData('description'), 'string', true);
     // Make sure all plugins are loaded for settings preload
     PluginRegistry::loadAllPlugins();
     HookRegistry::call('PressSiteSettingsForm::execute', array(&$this, &$press, &$series, &$isNewPress));
 }
 $index = substr($keys[$i], -1, 1);
 if (!isset($_POST["layout_id_" . $index]) || is_null($_POST["layout_id_" . $index]) || empty($_POST["layout_id_" . $index])) {
     $number_lots = $_POST["number_lots_" . $index];
     $number_units = $_POST["number_units_" . $index];
     $run_style = $_POST["run_style_" . $index];
     $format = $_POST["press_format"];
     $layoutLine = new Layoutline();
     $layoutLine->name = $component->genLayoutname($index, $component->name);
     $layoutLine->number_lots = $number_lots;
     $layoutLine->number_units = $number_units;
     $layoutLine->run_style = $run_style;
     $layoutLine->format = $format;
     $layoutLine->component_id = $component->id;
     $layoutLine->save();
     //Create press, presslines and pass data
     $press = new Press();
     $pressLine = new Pressline();
     $press_machine = $component->get_pressmachine_by_format($format);
     $press->pressmachine_id = $press_machine['id'];
     $press->pressmachine_name = $press_machine['name'];
     $press->save();
     $pressLine->component_id = $component->id;
     $pressLine->press_id = $press->id;
     $pressLine->layout_name = $layoutLine->name;
     $pressLine->layout_id = $layoutLine->id;
     $pressLine->part = "100";
     $pressLine->save();
 }
 if (isset($_POST["layout_id_" . $index]) && !is_null($_POST["layout_id_" . $index]) && !empty($_POST["layout_id_" . $index])) {
     $layout_id = $_POST["layout_id_" . $index];
     $format = $_POST["press_format"];
 public function actionAjax()
 {
     if (isset($_POST)) {
         switch ((int) $_POST['type']) {
             case 1:
                 //Смена статуса
                 $model = $this->loadModel((int) $_POST['id']);
                 $model->status = $model->status == 1 ? 0 : 1;
                 $model->save();
                 //Меняем статус для новостей в группе
                 foreach (Press::model()->findAll('group_id = ' . $model->id) as $data) {
                     $data->status = $model->status;
                     $data->save();
                 }
                 break;
         }
         echo CJavaScript::jsonEncode('ok');
     }
     Yii::app()->end();
 }
Beispiel #9
0
		 <div class="col-sm-10">
		<?php 
echo $form->textField($model, 'url', array('class' => 'form-control', 'maxlength' => 255, 'placeholder' => 'Url'));
?>
		<?php 
echo $form->error($model, 'url');
?>
		</div>
	</div>
	<div class="form-group">
                <?php 
echo $form->labelEx($model, 'status', array('class' => 'col-sm-2 control-label'));
?>
                <div class="col-sm-10">
                <?php 
echo $form->dropDownList($model, 'status', Press::getStatusNames(), array('encode' => false, 'class' => 'form-control', 'options' => array(Press::STATUS_ACTIVE => array('selected' => 'selected'))));
?>
                </div>
        </div>
    
         <div class="form-group">
        <?php 
echo $form->label($model, 'image', array('class' => 'col-sm-2 control-label'));
?>
        <div class="col-sm-10">
        <?php 
$this->widget('ext.dropzone.EDropzone', array('id' => 'part' . $model->id, 'model' => $model, 'name' => 'image', 'attribute' => 'image', 'formId' => 'press-form', 'sizeLimit' => $sizeLimit, 'deleteFile' => Yii::app()->createAbsoluteUrl('/admin/article/deletefile'), 'unlinkFile' => Yii::app()->createAbsoluteUrl('/file/upload/unlink', array('uploadsession' => $this->uploadsession)), 'url' => $this->createAbsoluteUrl('/file/upload/upload', array('inputName' => 'image', 'uploadsession' => $this->uploadsession)), 'options' => array()));
?>
 
        <?php 
echo $form->error($model, 'image');
Beispiel #10
0
<legend><?php 
echo Yii::t("Bootstrap", "LIST.Press");
?>
</legend>

<?php 
$assetsDir = Yii::app()->basePath;
$labels = Press::model()->attributeLabels();
$this->widget('bootstrap.widgets.TbExtendedGridView', array('id' => 'pages-grid', 'template' => "{items}\n{pager}", 'enableHistory' => true, 'dataProvider' => $model->search(), 'filter' => null, 'bulkActions' => array('actionButtons' => $this->bulkRemoveButton(), 'checkBoxColumnConfig' => array('name' => 'id')), 'columns' => array(array('header' => $labels["id"], 'name' => "id"), array('header' => $labels["name"], 'name' => "name"), array('header' => $labels["brieftext"], 'name' => "brieftext"), array('header' => 'Статус', 'name' => "status", 'type' => 'raw', 'value' => function ($data) {
    return '
                    <a href="#" class="on-off-product" data-id="' . $data->id . '" data-status="' . $data->status . '">
                        <div style="margin-left:20px; width: 13px; height: 13px; border-radius: 3px; background:' . ($data->status == 1 ? 'green' : 'red') . '"></div>
                    </a>
                ';
}, 'filter' => ''), array('class' => 'bootstrap.widgets.TbButtonColumn', 'template' => '{update}  {delete}', 'buttons' => array('update' => array('label' => yii::t('Bootstrap', 'PHRASE.UPDATE'), 'url' => 'CHtml::normalizeUrl(array("update", "id" => $data->id))', 'options' => array()), 'delete' => array('label' => yii::t('Bootstrap', 'PHRASE.DELETE'), 'options' => array())), 'htmlOptions' => array('style' => 'white-space: nowrap')))));
?>

<a href="/admin/<?php 
echo Yii::app()->controller->module->id;
?>
/<?php 
echo Yii::app()->controller->id;
?>
/create" class="btn">Добавить новость</a>

<script>
    //Меняем статус
    $(document).on('click', '.on-off-product', function(){
        $.ajax({
            type: 'POST',
Beispiel #11
0
?>
        <br>
        <?php 
echo CHtml::activeFileField($model, 'imagefile', array('style' => 'cursor: pointer;'));
?>
    </div>
</div>


<?php 
echo $form->DatePickerRow($model, 'maindate', array('options' => array('autoclose' => true, 'type' => 'Component', 'format' => 'yyyy-mm-dd'), 'htmlOptions' => array()));
?>


<?php 
echo $form->dropDownListRow($model, 'status', Press::model()->getStatuslist(), array('class' => 'span5'));
?>


	<div class="form-actions">

		<?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'htmlOptions' => array('style' => 'margin-right: 20px'), 'label' => $model->isNewRecord ? Yii::t('Bootstrap', 'PHRASE.BUTTON.CREATE') : Yii::t('Bootstrap', 'PHRASE.BUTTON.SAVE')));
?>

        <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'link', 'label' => Yii::t('Bootstrap', 'PHRASE.BUTTON.RETURN'), 'url' => $this->listUrl('index')));
?>

	</div>
Beispiel #12
0
 /**
  * @param bool $primary - выводить только те новости, у которых стоит признак "Главные новости"
  * @param int $count   -   количество новостей
  * @param int $sort   -  сортировка 1-по убыванию, 2-по возрастанию
  */
 public function getLastPress($primary = true, $count = 3, $sort = 1)
 {
     $retrnData = null;
     $paramArray = array();
     if ($primary == true) {
         $paramArray[] = '`primary`="1"';
     }
     $param = implode(" AND ", $paramArray);
     $param .= ' ORDER BY maindate ' . ($sort == 1 ? 'DESC' : 'ASC');
     $i = 0;
     foreach (Press::model()->findAll($param) as $data) {
         $retrnData[] = $data;
         if ($i < (int) $count) {
             break;
         }
         ++$i;
     }
     return $retrnData;
 }
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'XTemplate/xtpl.php';
require_once 'data/Tracker.php';
require_once 'modules/Press/Press.php';
require_once 'include/time.php';
require_once 'modules/Press/Forms.php';
global $timedate;
global $app_strings;
global $app_list_strings;
global $current_language;
global $current_user;
global $sugar_version, $sugar_config;
$focus = new Press();
if (!empty($_REQUEST['record'])) {
    $focus->retrieve($_REQUEST['record']);
}
echo "\n<p>\n";
echo get_module_title($mod_strings['LBL_MODULE_NAME'], $mod_strings['LBL_MODULE_NAME'] . ": " . $focus->name, true);
echo "\n</p>\n";
global $theme;
$theme_path = "themes/" . $theme . "/";
$image_path = $theme_path . "images/";
require_once $theme_path . 'layout_utils.php';
$GLOBALS['log']->info("Press detail view");
$xtpl = new XTemplate('modules/Press/EditView.html');
/// Users Popup
$json = getJSONobj();
$popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array('id' => 'assigned_user_id', 'user_name' => 'assigned_user_name'));
Beispiel #14
0
 /**
  * @param $model - модель pressGroup
  * Возращает сформированый дизайн списка групп в соответствии с $model группы
  */
 public function returnDesignGroup($model)
 {
     //Серый
     $template_gray = '
         <section class="shadow mg-top-15">
             <div class="bg-gray pd-bottom-40 bottom-shadow">
                 <main class="all" role="main">
                     <div class="container">
                         <h1 class="caption-big">%name%</h1>
                         <a href="' . Yii::app()->request->requestUri . '/' . $model->url . '">
                         <figure class="main-pic" style="cursor: pointer;" >
                             %image%
                             <figcaption>
                                 %brieftext%
                             </figcaption>
                         </figure>
                         </a>
                     </div>
                 </main>
             </div>
         </section>
     ';
     //Белый
     $template_white = '
         <section class="metro pd-top-30 mg-bottom-30">
             <main class="all" role="main">
                 <div class="container">
                     <h2 class="main-caption">%name%</h2>
                     <a href="' . Yii::app()->request->requestUri . '/' . $model->url . '">
                     <figure class="main-pic" style="cursor: pointer;">
                         %image%
                         <figcaption>
                             %brieftext%
                         </figcaption>
                     </figure>
                     </a>
                 </div>
             </main>
         </section>
     ';
     $return = $template_white;
     if ($model->param_design == 2) {
         $return = $template_gray;
     }
     $return = str_replace("%name%", $model->name, $return);
     $return = str_replace("%image%", !empty($model->image) ? '<img src="/uploads/filestorage/press/rubrics/' . $model->id . '.' . $model->image . '">' : '', $return);
     $return = str_replace("%brieftext%", $model->brieftext, $return);
     $return = str_replace("%description%", $model->description, $return);
     $press_element = '';
     $i = 0;
     foreach (Press::model()->findAll('group_id = ' . $model->id . ' AND status!=0 ORDER BY id DESC') as $dataPress) {
         ++$i;
         if ($i % 2 != 0) {
             $press_element .= '<div class="press-line">';
         }
         $press_element .= PressGroup::model()->returnDesignElement($dataPress);
         if ($i % 2 == 0) {
             $press_element .= '</div>';
         }
     }
     $return = str_replace("%press_element%", $press_element, $return);
     return $return;
 }
 * License.
 *
 * All copies of the Covered Code must include on each user interface screen:
 *    (i) the "Powered by SugarCRM" logo and
 *    (ii) the SugarCRM copyright notice
 * in the same form as they appear in the distribution.  See full license for
 * requirements.
 *
 * The Original Code is: SugarCRM Open Source
 * The Initial Developer of the Original Code is SugarCRM, Inc.
 * Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
 * All Rights Reserved.
 * Contributor(s): ______________________________________.
 */
require_once 'modules/Press/Press.php';
$sugarbean = new Press();
// perform the delete if given a record to delete
if (empty($_REQUEST['record'])) {
    $GLOBALS['log']->info('delete called without a record id specified');
} else {
    $record = $_REQUEST['record'];
    $sugarbean->retrieve($record);
    if (!$sugarbean->ACLAccess('Delete')) {
        ACLController::displayNoAccess(true);
        sugar_cleanup(true);
    }
    $GLOBALS['log']->info("deleting record: {$record}");
    $sugarbean->mark_deleted($record);
}
// handle the return location variables
$return_module = empty($_REQUEST['return_module']) ? 'Press' : $_REQUEST['return_module'];