public function __construct($application)
 {
     parent::__construct($application);
     $this->initViewHelperPath();
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile(Zend_Registry::get('StaticBaseUrl') . 'application/modules/Activity/externals/scripts/core.js');
 }
Esempio n. 2
0
 /**
  * Returns CKEditor form field
  * @param string $name  Name used for generated field
  * @param string $value Content for CKEditor
  * @param array $attr Attributes for textarea
  */
 function rte($name, $value = null, $attr = array())
 {
     $baseUrl = str_replace('/index.php', '', str_replace('/dev.php', '', Zend_Controller_Front::getInstance()->getBaseUrl()));
     $headLink = new Zend_View_Helper_HeadLink();
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->headScript()->appendFile($baseUrl . '/js/ckeditor/ckeditor.js');
     $placeholder = new Zend_View_Helper_Placeholder();
     $placeholder->placeholder('jQuery')->captureStart();
     echo "CKEDITOR.replace( '" . $name . "' );";
     $placeholder->placeholder('jQuery')->captureEnd();
     return $this->view->formTextarea($name, $value, $attr);
 }
 /**
  * @group ZF-12287
  */
 public function testNoEscapeTrue()
 {
     $this->helper->appendScript('// some script' . PHP_EOL, 'text/javascript', array('noescape' => true));
     $test = $this->helper->toString();
     $this->assertNotContains('//<!--', $test);
     $this->assertNotContains('//-->', $test);
 }
Esempio n. 4
0
 public function appendFile($item)
 {
     if (!preg_match('/^http/i', $item)) {
         $item .= '?v=' . $this->_appversion;
     }
     parent::appendFile($item);
 }
Esempio n. 5
0
 /**
  * Prefixes a given script path with a base URL for scripts before  
  * rendering the markup for a script element to include it.
  *
  * @param stdClass $item Object representing the script to render
  * @param string $indent
  * @param string $escapeStart
  * @param string $escapeEnd
  *
  * @return string Markup for the rendered script element
  */
 public function itemToString($item, $indent, $escapeStart, $escapeEnd)
 {
     if (isset($item->attributes['src'])) {
         $item->attributes['src'] = WEB_JS . ltrim($item->attributes['src'], '/');
     }
     $result = parent::itemToString($item, $indent, $escapeStart, $escapeEnd);
     return $result;
 }
 /**
  * @group GH-515
  */
 public function testConditionalScriptNoIE()
 {
     $this->helper->setAllowArbitraryAttributes(true);
     $this->helper->appendFile('/js/foo.js', 'text/javascript', array('conditional' => '!IE'));
     $test = $this->helper->toString();
     $this->assertContains('<!--[if !IE]><!--><', $test);
     $this->assertContains('<!--<![endif]-->', $test);
 }
Esempio n. 7
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynblog/externals/scripts/jquery-1.5.1.min.js');
     $headScript->appendFile('application/modules/Ynblog/externals/scripts/jquery.divslideshow-1.2-min.js');
     // Number of blog display
     if ($this->_getParam('max') != '' && $this->_getParam('max') >= 0) {
         $limitFblog = $this->_getParam('max');
     } else {
         $limitFblog = 6;
     }
     // Get featured blogs
     $btable = Engine_Api::_()->getItemTable('blog');
     $select = $btable->select()->where("search = 1")->where("draft = 0")->where("is_approved = 1")->where("is_featured = 1")->order('RAND()')->limit($limitFblog);
     $this->view->blogs = $btable->fetchAll($select);
     $this->view->limit = $limitFblog;
 }
Esempio n. 8
0
 /**
  * @issue ZF-5435
  */
 public function testContainerMaintainsCorrectOrderOfItems()
 {
     $this->helper->offsetSetFile(1, 'test1.js');
     $this->helper->offsetSetFile(20, 'test2.js');
     $this->helper->offsetSetFile(10, 'test3.js');
     $this->helper->offsetSetFile(5, 'test4.js');
     $test = $this->helper->toString();
     $expected = '<script type="text/javascript" src="test1.js"></script>' . PHP_EOL . '<script type="text/javascript" src="test4.js"></script>' . PHP_EOL . '<script type="text/javascript" src="test3.js"></script>' . PHP_EOL . '<script type="text/javascript" src="test2.js"></script>';
     $this->assertEquals($expected, $test);
 }
 /**
  * Strategy pattern: Initialize the configuration.
  *
  * Change the script tags that are linked to a file used in the web page
  * according the configuration pararmeters
  *
  * See {@link \Zend_View}
  * See {@link \Zend_View_Helper_HeadScript}
  *
  * @param \Zend_Controller_Request_Abstract $request
  */
 public function init(\Zend_Controller_Request_Abstract $request)
 {
     $this->_headScript = $this->_getView()->headScript();
     foreach ($this->_options as $scriptFileId => $options) {
         if (!isset($options['src'])) {
             require_once 'Exception.php';
             throw new Exception('The definition of a script file element require at least
                         one minimum option parameter:\\"src\\"');
         }
         if (!isset($options['type'])) {
             $type = 'text/javascript';
         } else {
             $type = $options['type'];
         }
         if (isset($options['allowArbitraryAttributes'])) {
             $this->_headScript->setAllowArbitraryAttributes($options['allowArbitraryAttributes']);
         }
         if (!isset($options['attributes'])) {
             $options['attributes'] = array();
         }
         if (!isset($options['placement']) || strcasecmp('APPEND', $options['placement']) == 0) {
             $this->_headScript->appendFile($options['src'], $type, $options['attributes']);
         } else {
             if (strcasecmp('SET', $options['placement']) == 0) {
                 $this->_headScript->setFile($options['src'], $type, $options['attributes']);
             } else {
                 if (strcasecmp('PREPEND', $options['placement']) == 0) {
                     $this->_headScript->prependFile($options['src'], $type, $options['attributes']);
                 } else {
                     $this->_headScript->offsetSetFile(intval($options['placement']), $options['src'], $type, $options['attributes']);
                 }
             }
         }
     }
 }
Esempio n. 10
0
 public function testCannotNestCaptures()
 {
     $this->helper->headScript()->captureStart();
     echo "this is something captured";
     try {
         $this->helper->headScript()->captureStart();
         $this->helper->headScript()->captureEnd();
         $this->fail('Should not be able to nest captures');
     } catch (Zend_View_Exception $e) {
         $this->helper->headScript()->captureEnd();
         $this->assertContains('Cannot nest', $e->getMessage());
     }
     $this->helper->headScript()->captureEnd();
 }
Esempio n. 11
0
    public function testIndentationIsHonored()
    {
        $this->helper->setIndent(4);
        $this->helper->appendScript('
var foo = "bar";
document.write(foo.strlen());');
        $this->helper->appendScript('
var bar = "baz";
document.write(bar.strlen());');
        $string = $this->helper->toString();

        $scripts = substr_count($string, '    <script');
        $this->assertEquals(2, $scripts);
        $this->assertContains('    //', $string);
        $this->assertContains('    var', $string);
        $this->assertContains('    document', $string);
    }
Esempio n. 12
0
 /**
  * Retrieve string representation
  *
  * @param  string|int $indent
  * @return string
  */
 public function toString($indent = null)
 {
     // adds the automatic cache buster functionality
     foreach ($this as &$item) {
         if (!$this->_isValid($item)) {
             continue;
         }
         if (is_array($item->attributes)) {
             if (isset($item->attributes["src"])) {
                 $realFile = PIMCORE_DOCUMENT_ROOT . $item->attributes["src"];
                 if (file_exists($realFile)) {
                     $item->attributes["src"] = $item->attributes["src"] . "?_dc=" . filemtime($realFile);
                 }
             }
         }
     }
     return parent::toString($indent);
 }
Esempio n. 13
0
 /**
  * Retrieve string representation
  *
  * @param  string|int $indent
  * @return string
  */
 public function toString($indent = null)
 {
     foreach ($this as &$item) {
         if (!$this->_isValid($item)) {
             continue;
         }
         if ($this->isCacheBuster()) {
             // adds the automatic cache buster functionality
             if (is_array($item->attributes)) {
                 if (isset($item->attributes["src"])) {
                     $realFile = PIMCORE_DOCUMENT_ROOT . $item->attributes["src"];
                     if (file_exists($realFile)) {
                         $item->attributes["src"] = "/cache-buster-" . filemtime($realFile) . $item->attributes["src"];
                     }
                 }
             }
         }
         \Pimcore::getEventManager()->trigger("frontend.view.helper.head-script", $this, ["item" => $item]);
     }
     return parent::toString($indent);
 }
Esempio n. 14
0
 public function toString($indent = null)
 {
     $this->_files = array();
     // turn off errors for this code block, we are mucking with the loop structing in real time
     $errdis = ini_get('display_errors');
     $errlog = ini_get('error_reporting');
     ini_set('display_errors', 0);
     ini_set('error_reporting', 0);
     foreach ($this as $key => $item) {
         if (!empty($this[$key]->attributes['src'])) {
             $this->_files[] = array('modified' => $this->getFiletime($this[$key]->attributes['src']), 'fullpath' => Zend_Uri::check($this[$key]->attributes['src']) ? $this[$key]->attributes['src'] : $this->_path . '/' . basename($this[$key]->attributes['src']), 'filename' => basename($this[$key]->attributes['src']));
             $this->offsetUnset($key);
         }
     }
     // turn errors back on
     ini_set('display_errors', $errdis);
     ini_set('error_reporting', $errlog);
     if (!defined('USE_COMPILED_LIBRARIES') || USE_COMPILED_LIBRARIES !== 'true') {
         if (!file_exists($this->_path . '/' . $this->_state . '.combined.js') || $this->_checkModifiedDate($this->_path . '/' . $this->_state . '.combined.js')) {
             $this->_createCombined();
         }
         $this->appendScript(file_get_contents($this->_path . '/' . $this->_state . '.combined.js'));
     } else {
         if (!file_exists($this->_path . '/' . $this->_state . '.compiled.js') || $this->_checkModifiedDate($this->_path . '/' . $this->_state . '.compiled.js')) {
             if (!file_exists($this->_path . '/' . $this->_state . '.combined.js') || $this->_checkModifiedDate($this->_path . '/' . $this->_state . '.combined.js')) {
                 $this->_createCombined();
             }
             $this->_createCompiled();
         }
         if (file_exists($this->_path . '/' . $this->_state . '.compiled.js')) {
             $this->appendScript(file_get_contents($this->_path . '/' . $this->_state . '.compiled.js'));
         } else {
             $this->appendScript(file_get_contents($this->_path . '/' . $this->_state . '.combined.js'));
         }
     }
     return parent::toString();
 }
 /**
  * Constructor
  *
  * Set separator to PHP_EOL
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->setConfig();
 }
Esempio n. 16
0
 /**
  * Retrieve string representation
  *
  * @param  string|int $indent
  * @return string
  */
 public function toString($indent = null)
 {
     // if static pack enable use toStringPacked instead of toString
     if (self::$_packsEnable) {
         return $this->toStringPacked($indent);
     } else {
         return parent::toString($indent);
     }
 }
Esempio n. 17
0
 /**
  * Return headScript object
  *
  * Returns headScript helper object; optionally, allows specifying a script
  * or script file to include.
  *
  * @param  string $mode Script or file
  * @param  string $spec Script/url
  * @param  string $placement Append, prepend, or set
  * @param  array $attrs Array of script attributes
  * @param  string $type Script type and/or array of script attributes
  * @return Zend_View_Helper_HeadScript
  */
 public function bottomScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript')
 {
     return parent::headScript($mode, $spec, $placement, $attrs, $type);
 }
Esempio n. 18
0
 /**
  * Retrieve string representation
  *
  * @param  string|int $indent
  * @return string
  */
 public function toString($indent = null)
 {
     // if no static pack
     if (self::$_packsEnable == false) {
         return parent::toString($indent);
     }
     // looking for packs
     $container = array();
     foreach ($this as $item) {
         $itemPack = $this->_getItemPack($item);
         if (is_object($itemPack)) {
             $container[] = $itemPack;
         }
     }
     // display items
     $indent = null !== $indent ? $this->getWhitespace($indent) : $this->getIndent();
     if ($this->view) {
         $useCdata = $this->view->doctype()->isXhtml() ? true : false;
     } else {
         $useCdata = $this->useCdata ? true : false;
     }
     $escapeStart = $useCdata ? '//<![CDATA[' : '//<!--';
     $escapeEnd = $useCdata ? '//]]>' : '//-->';
     $items = array();
     foreach ($container as $item) {
         if (!$this->_isValid($item)) {
             continue;
         }
         // add prefix only if not contain "http://"
         self::_addItemSrcPrefix($item);
         $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd);
     }
     $return = implode($this->getSeparator(), $items);
     return $return;
 }
Esempio n. 19
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_past = $tab_week = $tab_month = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_past'])) {
         $tab_past = $params['tab_past'];
     }
     if ($tab_past) {
         $tab_enabled[] = 'past';
     }
     if (isset($params['tab_week'])) {
         $tab_week = $params['tab_week'];
     }
     if ($tab_week) {
         $tab_enabled[] = 'week';
     }
     if (isset($params['tab_month'])) {
         $tab_month = $params['tab_month'];
     }
     if ($tab_month) {
         $tab_enabled[] = 'month';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('event');
     $viewer = Engine_Api::_()->user()->getViewer();
     $oldTz = date_default_timezone_get();
     if ($viewer->getIdentity()) {
         date_default_timezone_set($viewer->timezone);
     }
     $date = date('Y-m-d H:i:s');
     date_default_timezone_set($oldTz);
     $time = strtotime($date);
     $sub = $time - time();
     //past event
     $select = $table->select()->where("endtime < FROM_UNIXTIME(?)", time())->order("starttime ASC")->limit($itemCount);
     $this->view->events_pastevent = $events_pastevent = $table->fetchAll($select);
     $week = (int) date('W', strtotime(date('Y-m-d H:i:s')));
     $subyear = 0;
     if ($week == 1) {
         $subyear = 1;
     }
     // last week
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}') - ?", $subyear)->where("WEEK(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = WEEK(date_sub('{$date}', INTERVAL 7 day))")->order("starttime ASC")->limit($itemCount);
     $this->view->events_preweek = $events_preweek = $table->fetchAll($select);
     //last month
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}') - ?", $subyear)->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH(date_sub('{$date}', INTERVAL 1 MONTH))")->order("starttime ASC")->limit($itemCount);
     $this->view->events_premonth = $events_premonth = $table->fetchAll($select);
     $eventIds = array();
     foreach ($events_pastevent as $e) {
         $eventIdsPast[] = $e->getIdentity();
     }
     foreach ($events_preweek as $e) {
         $eventIdsPreweek[] = $e->getIdentity();
     }
     foreach ($events_premonth as $e) {
         $eventIdsPremonth[] = $e->getIdentity();
     }
     $this->view->eventIdsPast = implode("_", $eventIdsPast);
     $this->view->eventIdsPreweek = implode("_", $eventIdsPreweek);
     $this->view->eventIdsPremonth = implode("_", $eventIdsPremonth);
 }
Esempio n. 20
0
 public function toString($indent = null)
 {
     // Return early if no minifier has been set up
     if (false === $this->_minifier || !$this->_minifier->doBundle()) {
         return parent::toString($indent);
     }
     $container = $this->getContainer();
     $container->ksort();
     $items = $container->getArrayCopy();
     // Collect JS files
     $compressable = array();
     foreach ($items as $key => $item) {
         if (isset($item->attributes['src'])) {
             $src = $item->attributes['src'];
             $file = basename($src);
             if (in_array($file, $this->doNotBundle)) {
                 continue;
             }
             // If the source refers to a local file, process it
             if (preg_match('~^(\\w+:)?//~', $src) === 0) {
                 $compressable[] = $item;
                 unset($items[$key]);
             }
         }
     }
     $container->exchangeArray($items);
     // Collect current data of the JS files
     $hash = '';
     $mtimes = array();
     foreach ($compressable as $item) {
         $file = $_SERVER['DOCUMENT_ROOT'] . $item->attributes['src'];
         if (Zend_Loader::isReadable($file)) {
             $hash .= $item->attributes['src'];
             $mtimes[] = filemtime($file);
         }
     }
     // Check if the original JS files have been updated since the
     // last minification
     $regenerate = true;
     $filename = sha1($hash) . ".js";
     $cachedir = $this->_minifier->getCacheDir();
     $path = $_SERVER['DOCUMENT_ROOT'] . $cachedir;
     // check directory exists. if not, create it
     if (!file_exists($path)) {
         mkdir($path, 0775, true);
     }
     if (file_exists($path . "/" . $filename)) {
         $mtime = filemtime($path . "/" . $filename);
         $regenerate = array_reduce($mtimes, function ($u, $v) use($mtime) {
             return $u || $v > $mtime;
         }, false);
     }
     // If any JS file has been updated since the last minification
     // collect the content again, and store it in the cached version
     if ($regenerate) {
         $jsContent = '';
         foreach ($compressable as $item) {
             $file = $_SERVER['DOCUMENT_ROOT'] . $item->attributes['src'];
             if (Zend_Loader::isReadable($file)) {
                 $jsContent .= file_get_contents($file) . PHP_EOL;
             }
         }
         $jsContent = $this->_minifier->minify($jsContent);
         file_put_contents($path . "/" . $filename, $jsContent);
     }
     //Some scripts should be before the bundle, some should be after... Some should even be inbetween... Need something smarter.
     $this->prependFile($cachedir . "/" . $filename);
     return parent::toString($indent);
 }
Esempio n. 21
0
 /**
  * Return headScript object
  *
  * Returns headScript helper object; optionally, allows specifying a script
  * or script file to include.
  *
  * @param  string $mode Script or file
  * @param  string $spec Script/url
  * @param  string $placement Append, prepend, or set
  * @param  array $attributes Array of script attributes
  * @param  string $type Script type and/or array of script attributes
  * @return Zend_View_Helper_HeadScript
  */
 public function headScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attributes = array(), $type = 'text/javascript')
 {
     $this->_proxy = null;
     return parent::headScript($mode, $spec, $placement, $attributes, $type);
 }
Esempio n. 22
0
 protected function _triggerMethodAsset()
 {
     // Get url
     $path = Zend_Controller_Front::getInstance()->getRouter()->assemble(array('controller' => 'utility', 'action' => 'tasks'), 'default', true) . '?notrigger=1' . '&pid=' . $this->_pid . '&mode=' . 'js';
     $url = $path;
     // Add to headScript
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile($url);
 }
Esempio n. 23
0
 public function indexAction()
 {
     // Don't render this if not authorized
     $viewer = Engine_Api::_()->user()->getViewer();
     $this->view->viewer_id = $viewer_id = $viewer->getIdentity();
     $subject = null;
     if (Engine_Api::_()->core()->hasSubject()) {
         // Get subject
         $subject = Engine_Api::_()->core()->getSubject();
         if (!$subject->authorization()->isAllowed($viewer, 'view')) {
             return $this->setNoRender();
         }
     }
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $actionTable = Engine_Api::_()->getDbtable('actions', 'ynfeed');
     $this->view->friendUsers = $friendUsers = Engine_Api::_()->ynfeed()->getViewerFriends($viewer);
     // Get some settings from Ynfeed settings
     $settings = Engine_Api::_()->getApi('settings', 'core');
     $this->view->autoUpdate = $settings->getSetting('ynfeed.autoupdate', true);
     $liveUpdateValue = $settings->getSetting('ynfeed.liveupdatevalue', 2);
     $liveUpdatePeriod = $settings->getSetting('ynfeed.liveupdateperiod', 'm');
     $updateSettings = 0;
     if ($liveUpdateValue) {
         switch ($liveUpdatePeriod) {
             case 'm':
                 $updateSettings = $liveUpdateValue * 60000;
                 break;
             case 'h':
                 $updateSettings = $liveUpdateValue * 60 * 60000;
                 break;
         }
     }
     $this->view->updateSettings = $updateSettings;
     $this->view->autoLoadMore = $autoLoadMore = $settings->getSetting('ynfeed.autoloadfeed', true);
     // Get some options
     $countAutoload = $request->getParam('countAutoload', 0);
     $this->view->countAutoload = $countAutoload + 1;
     $this->view->feedOnly = $feedOnly = $request->getParam('feedOnly', false);
     $this->view->length = $length = $request->getParam('limit', $settings->getSetting('activity.length', 15));
     if ($autoLoadMore) {
         $this->view->max_times = $settings->getSetting('ynfeed.length', 5);
     }
     $this->view->itemActionLimit = $itemActionLimit = $settings->getSetting('activity.userlength', 5);
     $this->view->viewAllLikes = $request->getParam('viewAllLikes', $request->getParam('show_likes', false));
     $this->view->viewAllComments = $request->getParam('viewAllComments', $request->getParam('show_comments', false));
     $this->view->getUpdate = $request->getParam('getUpdate');
     $this->view->checkUpdate = $request->getParam('checkUpdate');
     $this->view->action_id = $action_id = (int) $request->getParam('action_id');
     $this->view->post_failed = (int) $request->getParam('pf');
     // Open comment hidden
     $this->view->openHide = $openHide = $request->getParam('openHide', 0);
     if ($feedOnly) {
         $this->getElement()->removeDecorator('Title');
         $this->getElement()->removeDecorator('Container');
     }
     if ($length > 50) {
         $this->view->length = $length = 50;
     }
     $default_firstid = null;
     $listTypeFilter = array();
     $this->view->enableContentTabs = true;
     $this->view->actionFilter = $actionFilter = $request->getParam('actionFilter', 'all');
     $this->view->isFromTab = $request->getParam('isFromTab', false);
     $this->view->filterValue = $filterValue = $request->getParam('filterValue', '');
     if (!$feedOnly && empty($subject)) {
         // Start filter tabs
         $this->view->contentTabMax = $settings->getSetting('ynfeed.defaultvisible', 7);
         $enableContentTabs = 0;
         $contentTabs = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContentList(array('show' => 1, 'content_tab' => 1));
         $defaultcontentTab = $request->getParam('actionFilter');
         $i = 0;
         $friendListIcon = $networkIcon = $customIcon = "";
         $friendContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'member_list'));
         if ($friendContent) {
             $friendListIcon = $friendContent->getPhotoUrl();
         }
         $networkContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'only_network'));
         if ($networkContent) {
             $networkIcon = $networkContent->getPhotoUrl();
         }
         $customContent = Engine_Api::_()->getDbtable('contents', 'ynfeed')->getContents(array('filter_type' => 'custom_list'));
         if ($customContent) {
             $customIcon = $customContent->getPhotoUrl();
         }
         foreach ($contentTabs as $value) {
             if (empty($viewer_id) && in_array($value->filter_type, array('membership', 'user_saved', 'user_follow'))) {
                 continue;
             }
             $filterTabs[$i]['filter_type'] = $value->filter_type;
             $filterTabs[$i]['tab_title'] = $this->view->translate($value->resource_title);
             $filterTabs[$i]['list_id'] = $value->content_id;
             $icon_url = $value->getPhotoUrl();
             $filterTabs[$i]['icon_url'] = $icon_url;
             $i++;
             if (empty($defaultcontentTab)) {
                 $defaultcontentTab = $value->filter_type;
             }
         }
         if ($defaultcontentTab) {
             $this->view->actionFilter = $defaultcontentTab;
             if ($defaultcontentTab != 'all') {
                 $default_firstid = $actionTable->select()->from($actionTable, 'action_id')->order('action_id DESC')->limit(1)->query()->fetchColumn();
             }
         }
         // Filter by networks
         $enableNetworkListFilter = $settings->getSetting('ynfeed.networklist.filtering', 0);
         if ($viewer_id && $enableNetworkListFilter) {
             $networkLists = Engine_Api::_()->ynfeed()->getNetworks($enableNetworkListFilter, $viewer);
             $countNetworkLists = count($networkLists);
             if ($countNetworkLists) {
                 if (count($filterTabs) > $this->view->contentTabMax) {
                     $filterTabs[$i]['filter_type'] = "separator";
                 }
                 $i++;
                 foreach ($networkLists as $value) {
                     $filterTabs[$i]['filter_type'] = "network_list";
                     $filterTabs[$i]['tab_title'] = $value->getTitle();
                     $filterTabs[$i]['list_id'] = $value->getIdentity();
                     $filterTabs[$i]['icon_url'] = $networkIcon;
                     $i++;
                 }
             }
         }
         // Filter by friend list
         $userFriendListEnable = $settings->getSetting('user.friends.lists');
         $enableFriendListFilter = $userFriendListEnable && $settings->getSetting('ynfeed.friendlist.filtering', 1);
         if ($enableFriendListFilter) {
             $listTable = Engine_Api::_()->getItemTable('user_list');
             $lists = $listTable->fetchAll($listTable->select()->where('owner_id = ?', $viewer->getIdentity()));
             $countlistsLists = count($lists);
             if ($countlistsLists) {
                 if (count($filterTabs) > $this->view->contentTabMax) {
                     $filterTabs[$i]['filter_type'] = "separator";
                 }
                 $i++;
                 foreach ($lists as $value) {
                     $filterTabs[$i]['filter_type'] = "member_list";
                     $filterTabs[$i]['tab_title'] = $value->title;
                     $filterTabs[$i]['list_id'] = $value->list_id;
                     $filterTabs[$i]['icon_url'] = $friendListIcon;
                     $i++;
                 }
             }
         }
         // Filter by custom list
         $this->view->canCreateCustomList = 0;
         if ($viewer_id) {
             $this->view->canCreateCustomList = $settings->getSetting('ynfeed.customlist.filtering', 1);
             $customTypeLists = Engine_Api::_()->getDbtable('customtypes', 'ynfeed')->getCustomTypeList(array('enabled' => 1));
             $count = count($customTypeLists);
             if (empty($count)) {
                 $this->view->canCreateCustomList = 0;
             }
             if ($this->view->canCreateCustomList) {
                 $customLists = Engine_Api::_()->getDbtable('lists', 'ynfeed')->getMemberOfList($viewer, 'default');
                 $countCustomLists = count($customLists);
                 if ($countCustomLists) {
                     if (count($filterTabs) > $this->view->contentTabMax) {
                         $filterTabs[$i]['filter_type'] = "separator";
                         $i++;
                     }
                     foreach ($customLists as $value) {
                         $filterTabs[$i]['filter_type'] = "custom_list";
                         $filterTabs[$i]['tab_title'] = $value->title;
                         $filterTabs[$i]['list_id'] = $value->list_id;
                         $filterTabs[$i]['icon_url'] = $customIcon;
                         $i++;
                     }
                 }
             }
         }
         $this->view->filterTabs = $filterTabs;
         // End filter tabs
     }
     $actionTypeFilters = array();
     if ($actionFilter && !in_array($actionFilter, array('membership', 'owner', 'all', 'network_list', 'member_list', 'custom_list'))) {
         $actionTypesTable = Engine_Api::_()->getDbtable('actionTypes', 'ynfeed');
         $groupedActionTypes = $actionTypesTable->getEnabledGroupedActionTypes($actionFilter);
         if (isset($groupedActionTypes[$actionFilter])) {
             $actionTypeFilters = $groupedActionTypes[$actionFilter];
         }
     } elseif (in_array($actionFilter, array('member_list', 'custom_list')) && $filterValue != null) {
         $listTypeFilter = Engine_Api::_()->ynfeed()->getListBaseContent($actionFilter, array('filterValue' => $filterValue));
     } else {
         if ($actionFilter == 'network_list' && $filterValue != null) {
             $listTypeFilter = array($filterValue);
         }
     }
     // Get config options for activity
     $config = array('action_id' => $action_id, 'max_id' => (int) $request->getParam('maxid'), 'min_id' => (int) $request->getParam('minid'), 'limit' => (int) $length, 'showTypes' => $actionTypeFilters, 'actionFilter' => $actionFilter, 'filterValue' => $filterValue, 'listTypeFilter' => $listTypeFilter);
     // Pre-process feed items
     $selectCount = 0;
     $nextid = null;
     $firstid = null;
     $tmpConfig = $config;
     $activity = array();
     $endOfFeed = false;
     $friendRequests = array();
     $itemActionCounts = array();
     $enabledModules = Engine_Api::_()->getDbtable('modules', 'core')->getEnabledModuleNames();
     $hideItems = array();
     if ($viewer->getIdentity()) {
         $hideItems = Engine_Api::_()->getDbtable('hide', 'ynfeed')->getHideItemByMember($viewer);
     }
     if ($default_firstid) {
         $firstid = $default_firstid;
     }
     $tmpConfig['showTypes'] = array('advgroup_video_create');
     do {
         // Get current batch
         $actions = null;
         // Where the Activity Feed is Fetched
         if (!empty($subject)) {
             $actions = $actionTable->getActivityAbout($subject, $viewer, $tmpConfig);
         } else {
             $actions = $actionTable->getActivity($viewer, $tmpConfig);
         }
         $selectCount++;
         // Are we at the end?
         if (count($actions) < $length || count($actions) <= 0) {
             $endOfFeed = true;
         }
         // Pre-process
         if (count($actions) > 0) {
             foreach ($actions as $action) {
                 // get next id
                 if (null === $nextid || $action->action_id <= $nextid) {
                     $nextid = $action->action_id - 1;
                 }
                 // get first id
                 if (null === $firstid || $action->action_id > $firstid) {
                     $firstid = $action->action_id;
                 }
                 // skip disabled actions
                 if (!$action->getTypeInfo() || !@$action->getTypeInfo()->enabled) {
                     continue;
                 }
                 // skip items with missing items
                 if (@$action->subject_type == 'ynbusinesspages_business' && !Engine_Api::_()->hasModuleBootstrap('ynbusinesspages')) {
                     continue;
                 }
                 if (!@$action->getSubject() || !@$action->getSubject()->getIdentity()) {
                     continue;
                 }
                 if (!@$action->getObject() || !@$action->getObject()->getIdentity()) {
                     continue;
                 }
                 // skip the hide actions and content
                 if (!empty($hideItems) && !$action_id) {
                     if (isset($hideItems[$action->getType()]) && in_array($action->getIdentity(), $hideItems[$action->getType()])) {
                         continue;
                     }
                     if ($action->getSubject()->getType() == 'user' && isset($hideItems[$action->getSubject()->getType()]) && in_array($action->getSubject()->getIdentity(), $hideItems[$action->getSubject()->getType()])) {
                         continue;
                     }
                     if ($action->getSubject()->getType() == 'ynbusinesspages_business' && isset($hideItems[$action->getSubject()->getType()]) && in_array($action->getSubject()->getIdentity(), $hideItems[$action->getSubject()->getType()])) {
                         continue;
                     }
                 }
                 // track/remove users who do too much (but only in the main feed)
                 if (empty($subject)) {
                     $actionSubject = $action->getSubject();
                     $actionObject = $action->getObject();
                     if (!isset($itemActionCounts[$actionSubject->getGuid()])) {
                         $itemActionCounts[$actionSubject->getGuid()] = 1;
                     } else {
                         if ($itemActionCounts[$actionSubject->getGuid()] >= $itemActionLimit) {
                             continue;
                         } else {
                             $itemActionCounts[$actionSubject->getGuid()]++;
                         }
                     }
                 }
                 // remove duplicate friend requests
                 if ($action->type == 'friends') {
                     $id = $action->subject_id . '_' . $action->object_id;
                     $rev_id = $action->object_id . '_' . $action->subject_id;
                     if (in_array($id, $friendRequests) || in_array($rev_id, $friendRequests)) {
                         continue;
                     } else {
                         $friendRequests[] = $id;
                         $friendRequests[] = $rev_id;
                     }
                 }
                 // remove items with disabled module attachments
                 try {
                     $attachments = $action->getAttachments();
                 } catch (Exception $e) {
                     // if a module is disabled, getAttachments() will throw an Engine_Api_Exception; catch and continue
                     continue;
                 }
                 // add to list
                 if (count($activity) < $length) {
                     $activity[] = $action;
                     if (count($activity) == $length) {
                         $actions = array();
                     }
                 }
             }
         }
         // Set next tmp max_id
         if ($nextid) {
             $tmpConfig['max_id'] = $nextid;
         }
         if (!empty($tmpConfig['action_id'])) {
             $actions = array();
         }
     } while (count($activity) < $length && $selectCount <= 3 && !$endOfFeed);
     if (count($activity) == 0) {
         $this->view->endOfFeed = true;
         $this->view->noFeed = true;
     } else {
         $this->view->noFeed = false;
     }
     $this->view->activity = $activity;
     $this->view->activityCount = count($activity);
     $this->view->nextid = $nextid;
     $this->view->firstid = $firstid;
     $this->view->endOfFeed = $endOfFeed;
     // Get some other info
     if (!empty($subject)) {
         $this->view->subjectGuid = $subject->getGuid(false);
     }
     $this->view->enableComposer = false;
     if ($viewer->getIdentity()) {
         if (!$subject || $subject instanceof Core_Model_Item_Abstract && $subject->isSelf($viewer)) {
             if (Engine_Api::_()->authorization()->getPermission($viewer->level_id, 'user', 'status')) {
                 $this->view->enableComposer = true;
             }
         } else {
             if ($subject) {
                 if (Engine_Api::_()->authorization()->isAllowed($subject, $viewer, 'comment')) {
                     $this->view->enableComposer = true;
                 }
             }
         }
     }
     $this->view->enableComposer = false;
     // Assign the composing values
     $composePartials = array();
     foreach (Zend_Registry::get('Engine_Manifest') as $data) {
         if (empty($data['composer'])) {
             continue;
         }
         foreach ($data['composer'] as $type => $config) {
             if (!empty($config['auth']) && !Engine_Api::_()->authorization()->isAllowed($config['auth'][0], null, $config['auth'][1])) {
                 continue;
             }
             $composePartials[] = $config['script'];
         }
     }
     $this->view->composePartials = $composePartials;
     // Add javascript
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/core.js');
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yncomposer.js');
     //update to support Video 487
     $headScript->appendFile('externals/mdetect/mdetect' . (APPLICATION_ENV != 'development' ? '.min' : '') . '.js');
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynfeed.js');
     if ($viewer->getIdentity()) {
         // Support tags
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yntag.js');
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddfriend.js');
         $this->view->hasTag = true;
         // Checkin JS
         $headScript->appendFile('//maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=places');
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/yncheckin.js');
     }
     // Auto scroll
     $headScript->appendFile('application/modules/Ynfeed/externals/scripts/scrollspy.1.2.js');
     if ($viewer && ($subject && $viewer->isSelf($subject) || !$subject || $subject && in_array($subject->getType(), array('event', 'group', 'ynbusinesspages_business')))) {
         // Add privacy
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddprivacies.js');
         $this->view->hasPrivacy = true;
     }
     if (Engine_Api::_()->hasModuleBootstrap('ynbusinesspages')) {
         $headScript->appendFile('application/modules/Ynfeed/externals/scripts/ynaddbusiness.js');
     }
     // Form token
     $session = new Zend_Session_Namespace('ActivityFormToken');
     if (empty($session->token)) {
         $this->view->formToken = $session->token = md5(time() . $viewer->getIdentity() . get_class($this));
     } else {
         $this->view->formToken = $session->token;
     }
     //Fix for Vincent
     $actionTable = Engine_Api::_()->getDbtable('actions', 'ynfeed');
     $Name = $actionTable->info('name');
     $select = $actionTable->select()->from($Name, array('action_id'))->order('action_id DESC')->limit(1);
     $result = $actionTable->fetchRow($select);
     $this->view->last_id_pva = $result->action_id;
     $this->view->firstid = $result->action_id;
 }
Esempio n. 24
0
 /**
  * 
  * Gets a string representation of the headscripts suitable for inserting
  * in the html head section. All included javascript files will be minified
  * and any script sections will remain as is. 
  * 
  * It is important to note that the minified javascript files will be minified
  * in reverse order of being added to this object, and ALL files will be rendered
  * prior to inline scripts being rendered.
  *
  * @see Zend_View_Helper_HeadScript->toString()
  * @param  string|int $indent
  * @return string
  */
 public function toString($indent = null)
 {
     if (!$this->_doMinify) {
         return parent::toString($indent);
         // Do not minify output
     }
     // An array of Script Items to be rendered
     $items = array();
     // An array of Javascript Items
     $scripts = array();
     // Any indentation we should use.
     $indent = null !== $indent ? $this->getWhitespace($indent) : $this->getIndent();
     // Determining the appropriate way to handle inline scripts
     if ($this->view) {
         $useCdata = $this->view->doctype()->isXhtml() ? true : false;
     } else {
         $useCdata = $this->useCdata ? true : false;
     }
     $escapeStart = $useCdata ? '//<![CDATA[' : '//<!--';
     $escapeEnd = $useCdata ? '//]]>' : '//-->';
     $this->getContainer()->ksort();
     $groupIndex = 0;
     foreach ($this as $i => $item) {
         if ($this->_isNeedToMinify($item)) {
             if (!empty($item->attributes['minify_split_before']) || !empty($item->attributes['minify_split'])) {
                 $items[] = $this->_generateMinifyItem($scripts);
                 $scripts = array();
             }
             $scripts[] = $item->attributes['src'];
             if (!empty($item->attributes['minify_split_after']) || !empty($item->attributes['minify_split'])) {
                 $items[] = $this->_generateMinifyItem($scripts);
                 $scripts = array();
             }
         } else {
             if ($scripts) {
                 $items[] = $this->_generateMinifyItem($scripts);
                 $scripts = array();
             }
             $items[] = $this->itemToString($item, $indent, $escapeStart, $escapeEnd);
         }
     }
     if ($scripts) {
         $items[] = $this->_generateMinifyItem($scripts);
     }
     return $indent . implode($this->_escape($this->getSeparator()) . $indent, $items);
 }
Esempio n. 25
0
 private function addToHead($config, $stylesheet_dir = '', $js_dir = '', $head, $baseUrl, $yui_dir = '')
 {
     // Add CSS
     if (isset($config->style->screen->stylesheet) && $config->style->screen->stylesheet != '') {
         $css = explode(',', $config->style->screen->stylesheet);
         foreach ($css as $s) {
             if (@substr_compare(trim($s), 'http', 0, 4) == 0) {
                 $head->headLink()->appendStylesheet(trim($s), 'screen');
             } else {
                 $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s), 'screen');
             }
         }
     }
     // IE stylesheet
     if (isset($config->ie->screen->stylesheet) && $config->ie->screen->stylesheet != '') {
         $css = explode(',', $config->ie->screen->stylesheet);
         foreach ($css as $s) {
             if (@substr_compare(trim($s), 'http', 0, 4) == 0) {
                 $head->headLink()->appendStylesheet(trim($s), 'screen', 'IE');
             } else {
                 $head->headLink()->appendStylesheet(str_replace('//', '/', $this->baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s)), 'screen', 'IE');
             }
         }
     }
     if (isset($config->style->print->stylesheet) && $config->style->print->stylesheet != '') {
         $css = explode(',', $config->style->print->stylesheet);
         foreach ($css as $s) {
             if (@substr_compare(trim($s), 'http', 0, 4) == 0) {
                 $head->headLink()->appendStylesheet(trim($s), 'print');
             } else {
                 $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s), 'print');
             }
         }
     }
     // yui
     if (isset($config->yui->css) && $config->yui->css != '') {
         $css = explode(',', $config->yui->css);
         foreach ($css as $s) {
             if (@substr_compare(trim($s), 'http', 0, 4) == 0) {
                 $head->headLink()->appendStylesheet(trim($s), 'screen');
             } else {
                 $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $yui_dir . DIRECTORY_SEPARATOR . trim($s), 'screen');
             }
         }
     }
     // Add JS
     $headScript = new Zend_View_Helper_HeadScript();
     if (isset($config->js->js) && $config->js->js != '') {
         $js = explode(',', $config->js->js);
         foreach ($js as $j) {
             if (@substr_compare(trim($j), 'http', 0, 4) == 0) {
                 $headScript->headScript()->appendFile(trim($j));
             } else {
                 $headScript->headScript()->appendFile($baseUrl . DIRECTORY_SEPARATOR . $js_dir . DIRECTORY_SEPARATOR . trim($j));
             }
         }
     }
     if (isset($config->js->prepend) && $config->js->prepend != '') {
         $js = array_reverse(explode(',', $config->js->prepend));
         foreach ($js as $j) {
             if (@substr_compare(trim($j), 'http', 0, 4) == 0) {
                 $headScript->headScript()->prependFile(trim($j));
             } else {
                 $headScript->headScript()->prependFile($baseUrl . DIRECTORY_SEPARATOR . $js_dir . DIRECTORY_SEPARATOR . trim($j));
             }
         }
     }
     // yui
     if (isset($config->yui->js) && $config->yui->js != '') {
         $js = explode(',', $config->yui->js);
         foreach ($js as $j) {
             if (@substr_compare(trim($j), 'http', 0, 4) == 0) {
                 $headScript->headScript()->appendFile(trim($j));
             } else {
                 $headScript->headScript()->appendFile($baseUrl . DIRECTORY_SEPARATOR . $yui_dir . DIRECTORY_SEPARATOR . trim($j));
             }
         }
     }
 }
Esempio n. 26
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_upcoming = $tab_today = $tab_week = $tab_month = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_upcoming'])) {
         $tab_upcoming = $params['tab_upcoming'];
     }
     if ($tab_upcoming) {
         $tab_enabled[] = 'upcoming';
     }
     if (isset($params['tab_today'])) {
         $tab_today = $params['tab_today'];
     }
     if ($tab_today) {
         $tab_enabled[] = 'today';
     }
     if (isset($params['tab_week'])) {
         $tab_week = $params['tab_week'];
     }
     if ($tab_week) {
         $tab_enabled[] = 'week';
     }
     if (isset($params['tab_month'])) {
         $tab_month = $params['tab_month'];
     }
     if ($tab_month) {
         $tab_enabled[] = 'month';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     $table = Engine_Api::_()->getItemTable('event');
     $tableName = $table->info('name');
     $viewer = Engine_Api::_()->user()->getViewer();
     $oldTz = date_default_timezone_get();
     if ($viewer->getIdentity()) {
         date_default_timezone_set($viewer->timezone);
     }
     $date = date('Y-m-d H:i:s');
     date_default_timezone_set($oldTz);
     $time = strtotime($date);
     $sub = $time - time();
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     //upcoming event
     // membership
     $membershipTb = Engine_Api::_()->getDbtable('membership', 'ynevent');
     $membershipName = $membershipTb->info('name');
     $select = $membershipTb->getMembershipsOfSelect($viewer);
     $select->where("{$tableName}.endtime > FROM_UNIXTIME(?)", $time)->order("{$membershipName}.rsvp DESC")->order("{$tableName}.starttime ASC")->limit($itemCount);
     $events_upcoming = $table->fetchAll($select);
     if (count($events_upcoming) < $itemCount) {
         $select = $table->select();
         $select->where("{$tableName}.endtime > FROM_UNIXTIME(?)", $time)->order("{$tableName}.starttime ASC")->limit($itemCount - count($events_upcoming));
         $otherEvents = $table->fetchAll($select);
         foreach ($otherEvents as $otherEvent) {
             $events_upcoming[] = $otherEvent;
         }
     }
     $this->view->events_upcoming = $events_upcoming;
     // today
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH('{$date}')")->where("DAY(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = DAY('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_today = $events_today = $table->fetchAll($select);
     // this week
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("WEEK(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = WEEK('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_week = $events_week = $table->fetchAll($select);
     //this month
     $select = $table->select()->where("YEAR(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = YEAR('{$date}')")->where("MONTH(FROM_UNIXTIME(UNIX_TIMESTAMP(starttime) + {$sub})) = MONTH('{$date}')")->order("starttime ASC")->limit($itemCount);
     $this->view->events_month = $events_month = $table->fetchAll($select);
     $eventIdsUpcoming = $eventIdsToday = $eventIdsWeek = $eventIdsMonth = array();
     foreach ($events_upcoming as $e) {
         $eventIdsUpcoming[] = $e->getIdentity();
     }
     foreach ($events_today as $e) {
         $eventIdsToday[] = $e->getIdentity();
     }
     foreach ($events_week as $e) {
         $eventIdsWeek[] = $e->getIdentity();
     }
     foreach ($events_month as $e) {
         $eventIdsMonth[] = $e->getIdentity();
     }
     $this->view->eventIdsUpcoming = implode("_", $eventIdsUpcoming);
     $this->view->eventIdsToday = implode("_", $eventIdsToday);
     $this->view->eventIdsWeek = implode("_", $eventIdsWeek);
     $this->view->eventIdsMonth = implode("_", $eventIdsMonth);
 }
Esempio n. 27
0
 public function toString($indent = null)
 {
     $strings = parent::toString($indent);
     $headbase = new Evil_Cdn_HeadBase('js');
     return $headbase->toString($strings);
 }
Esempio n. 28
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Ynevent/externals/scripts/YneventTabContent.js');
     $params = $this->_getAllParams();
     $tab_popular = $tab_attending = $tab_liked = $tab_rated = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_popular'])) {
         $tab_popular = $params['tab_popular'];
     }
     if ($tab_popular) {
         $tab_enabled[] = 'popular';
     }
     if (isset($params['tab_attending'])) {
         $tab_attending = $params['tab_attending'];
     }
     if ($tab_attending) {
         $tab_enabled[] = 'attending';
     }
     if (isset($params['tab_liked'])) {
         $tab_liked = $params['tab_liked'];
     }
     if ($tab_liked) {
         $tab_enabled[] = 'liked';
     }
     if (isset($params['tab_rated'])) {
         $tab_rated = $params['tab_rated'];
     }
     if ($tab_rated) {
         $tab_enabled[] = 'rated';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "ynevent_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "ynevent_grid-view";
             break;
         case 'map':
             $class_mode = "ynevent_map-view";
             break;
         default:
             $class_mode = "ynevent_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('event');
     $request = Zend_Controller_Front::getInstance()->getRequest();
     $filter = $request->getParam('filter', 'future');
     if ($filter == 'future') {
         $filter = ">";
     } else {
         $filter = "<";
     }
     //popular event
     $select = $table->select()->where('search = ?', 1)->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order('view_count')->limit($itemCount);
     $this->view->events_popular = $events_popular = $table->fetchAll($select);
     // most attending
     $tableEventName = $table->info('name');
     $select = $table->select()->limit($itemCount);
     $tableMembership = Engine_Api::_()->getDbTable('membership', 'ynevent');
     $tableMembershipName = $tableMembership->info('name');
     $select->setIntegrityCheck(false)->from($tableEventName, array("{$tableEventName}.*", "count({$tableMembershipName}.resource_id)as member_attending"))->join($tableMembershipName, "{$tableMembershipName}.resource_id={$tableEventName}.event_id", '')->where("{$tableMembershipName}.rsvp = ?", 2)->group("{$tableMembershipName}.resource_id")->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order("count({$tableMembershipName}.resource_id) DESC")->limit($itemCount);
     $this->view->events_attending = $events_attending = $table->fetchAll($select);
     //most liked
     $ltable = Engine_Api::_()->getDbtable('likes', 'core');
     $Name = $table->info('name');
     $lName = $ltable->info('name');
     $select = $table->select()->from($Name, "{$Name}.*,count({$lName}.like_id)as liked_count");
     $select->joinLeft($lName, "resource_id = {$Name}.event_id AND resource_type LIKE 'event'", '')->group("{$Name}.event_id")->order("Count({$lName}.like_id) DESC");
     $select->where("search = ?", "1")->where("endtime {$filter} FROM_UNIXTIME(?)", time());
     $events = $table->fetchAll($select);
     $this->view->events_liked = $events_liked = Ynevent_Plugin_Utilities::getListOfEvents($events, $itemCount);
     //most rated
     $select = $table->select();
     $tableEventName = $table->info('name');
     $tableRating = Engine_Api::_()->getDbTable('ratings', 'ynevent');
     $tableRatingName = $tableRating->info('name');
     $select->setIntegrityCheck(false)->from($tableEventName, array("{$tableEventName}.*", "count({$tableRatingName}.event_id)as rating_count"))->join($tableRatingName, "{$tableRatingName}.event_id={$tableEventName}.event_id", '')->where("{$tableEventName}.search = ?", 1)->group("{$tableRatingName}.event_id")->where("endtime {$filter} FROM_UNIXTIME(?)", time())->order("{$tableEventName}.rating DESC");
     $this->view->events_rated = $events_rated = Zend_Paginator::factory($select);
     $eventIdsPopular = $eventIdsAttending = $eventIdsLiked = $eventIdsRated = array();
     foreach ($events_popular as $e) {
         $eventIdsPopular[] = $e->getIdentity();
     }
     foreach ($events_attending as $e) {
         $eventIdsAttending[] = $e->getIdentity();
     }
     foreach ($events_liked as $e) {
         $eventIdsLiked[] = $e->getIdentity();
     }
     foreach ($events_rated as $e) {
         $eventIdsRated[] = $e->getIdentity();
     }
     $this->view->eventIdsPopular = implode("_", $eventIdsPopular);
     $this->view->eventIdsAttending = implode("_", $eventIdsAttending);
     $this->view->eventIdsLiked = implode("_", $eventIdsLiked);
     $this->view->eventIdsRated = implode("_", $eventIdsRated);
 }
Esempio n. 29
0
 /**
  * Iterates over scripts, concatenating, optionally minifying, 
  * optionally compressiong, and caching them.
  * 
  * This detects updates to the source javascripts using filemtime.
  * A file with an mtime more recent than the mtime of the cached bundle will
  * invalidate the cached bundle.
  * 
  * Modifications of captured scripts cannot be detected by this.
  * DONT USE DYNAMICALLY GENERATED CAPTURED SCRIPTS.
  * 
  * 
  *
  * @param string $indent 
  * @return void
  * @throws UnexpectedValueException if item has no src attribute or contains no captured source
  */
 public function toString($indent = null)
 {
     if (isset($_REQUEST['bundle_off'])) {
         return parent::toString($indent);
     }
     $this->getContainer()->ksort();
     $filelist = '';
     $mostrecent = 0;
     foreach ($this as $item) {
         if (!$this->_isValid($item)) {
             continue;
         }
         if (isset($item->attributes['src'])) {
             $src = $item->attributes['src'];
             if ($this->_baseUrl && strpos($src, $this->_baseUrl) !== false) {
                 $src = substr($src, strlen($this->_baseUrl));
             }
             $mtime = filemtime($this->_docRoot . $src);
             if ($mtime > $mostrecent) {
                 $mostrecent = $mtime;
             }
         } else {
             if (!empty($item->source)) {
                 // BEWARE: Cannot detect modification of captured scripts!
                 $src = $item->source;
             } else {
                 throw new UnexpectedValueException("Item has no src attribute nor captured source.");
             }
         }
         $filelist .= $src;
     }
     $hash = md5($filelist);
     $cacheFile = "{$this->_cacheDir}/bundle_{$hash}.js";
     // suppress warning for file DNE
     if (file_exists($cacheFile)) {
         $cacheTime = filemtime($cacheFile);
     } else {
         $cacheTime = false;
     }
     if (false === $cacheTime || $cacheTime < $mostrecent) {
         if (!($data = $this->_getJsData())) {
             return "";
         }
         $this->_writeUncompressed($cacheFile, $data);
         if ($this->_doGzip) {
             $this->_writeCompressed($cacheFile, $data);
         }
         $cacheTime = filemtime($cacheFile);
     }
     $urlPath = "{$this->_baseUrl}/{$this->_urlPrefix}/bundle_{$hash}.js?{$cacheTime}";
     $ret = '<script type="text/javascript" src="' . $urlPath . '"></script>';
     return $ret;
 }
Esempio n. 30
0
 public function indexAction()
 {
     $headScript = new Zend_View_Helper_HeadScript();
     $headScript->appendFile('application/modules/Advgroup/externals/scripts/AdvgroupTabContent.js');
     $params = $this->_getAllParams();
     $tab_recent = $tab_popular = $tab_active = $tab_directory = $mode_list = $mode_grid = $mode_map = 1;
     $tab_enabled = $mode_enabled = array();
     $view_mode = 'list';
     if (isset($params['tab_popular'])) {
         $tab_popular = $params['tab_popular'];
     }
     if ($tab_popular) {
         $tab_enabled[] = 'popular';
     }
     if (isset($params['tab_recent'])) {
         $tab_recent = $params['tab_recent'];
     }
     if ($tab_recent) {
         $tab_enabled[] = 'recent';
     }
     if (isset($params['tab_active'])) {
         $tab_active = $params['tab_active'];
     }
     if ($tab_active) {
         $tab_enabled[] = 'active';
     }
     if (isset($params['tab_directory'])) {
         $tab_directory = $params['tab_directory'];
     }
     if ($tab_directory) {
         $tab_enabled[] = 'directory';
     }
     if (isset($params['mode_list'])) {
         $mode_list = $params['mode_list'];
     }
     if ($mode_list) {
         $mode_enabled[] = 'list';
     }
     if (isset($params['mode_grid'])) {
         $mode_grid = $params['mode_grid'];
     }
     if ($mode_grid) {
         $mode_enabled[] = 'grid';
     }
     if (isset($params['mode_map'])) {
         $mode_map = $params['mode_map'];
     }
     if ($mode_map) {
         $mode_enabled[] = 'map';
     }
     if (isset($params['view_mode'])) {
         $view_mode = $params['view_mode'];
     }
     if ($mode_enabled && !in_array($view_mode, $mode_enabled)) {
         $view_mode = $mode_enabled[0];
     }
     $this->view->tab_enabled = $tab_enabled;
     $this->view->mode_enabled = $mode_enabled;
     $class_mode = "advgroup_list-view";
     switch ($view_mode) {
         case 'grid':
             $class_mode = "advgroup_grid-view";
             break;
         case 'map':
             $class_mode = "advgroup_map-view";
             break;
         default:
             $class_mode = "advgroup_list-view";
             break;
     }
     $this->view->class_mode = $class_mode;
     $this->view->view_mode = $view_mode;
     if (!$tab_enabled) {
         $this->setNoRender();
     }
     $itemCount = $this->_getParam('itemCountPerPage', 6);
     if (!$itemCount) {
         $itemCount = 6;
     }
     $this->view->itemCount = $itemCount;
     $table = Engine_Api::_()->getItemTable('group');
     $request = Zend_Controller_Front::getInstance()->getRequest();
     // recent groups
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $recentType = $this->_getParam('recentType', 'creation');
     if (!in_array($recentType, array('creation', 'modified'))) {
         $recentType = 'creation';
     }
     $this->view->recentType = $recentType;
     $this->view->recentCol = $recentCol = $recentType . '_date';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where("is_subgroup = ?", 0)->limit($count);
     if ($recentType == 'creation') {
         // using primary should be much faster, so use that for creation
         $select->order('group_id DESC');
     } else {
         $select->order($recentCol . ' DESC');
     }
     $this->view->recentgroups = $groups = $table->fetchAll($select);
     $this->view->limit = $count;
     // Hide if nothing to show
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //most popular groups
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $popularType = $this->_getParam('popularType', 'member');
     if (!in_array($popularType, array('view', 'member'))) {
         $popularType = 'member';
     }
     $this->view->popularType = $popularType;
     $this->view->popularCol = $popularCol = $popularType . '_count';
     // Get paginator
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where("is_subgroup = ?", 0)->order($popularCol . ' DESC')->limit($count);
     $this->view->populargroups = $groups = $table->fetchAll($select);
     $this->view->limit = $count;
     // Hide if nothing to show
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //most active group
     $count = $this->_getParam('itemCountPerPage');
     if (!is_numeric($count) | $count <= 0) {
         $count = 6;
     }
     $time = $this->_getParam('time', 1);
     if (!in_array($time, array(1, 2, 3))) {
         $time = 1;
     }
     $date = date('Y-m-d H:i:s');
     switch ($time) {
         case 1:
             $newdate = strtotime('-30 day', strtotime($date));
             break;
         case 2:
             $newdate = strtotime('-60 day', strtotime($date));
             break;
         case 3:
             $newdate = strtotime('-90 day', strtotime($date));
     }
     $newdate = date('Y-m-d H:i:s', $newdate);
     $topicTable = Engine_Api::_()->getItemTable('advgroup_topic');
     $topicName = $topicTable->info('name');
     $groupTable = Engine_Api::_()->getItemTable('group');
     $groupName = $groupTable->info('name');
     $select = $groupTable->select()->from($groupName, array("{$groupName}.*", "COUNT('topic_id') AS topic_count"))->setIntegrityCheck(false)->joinRight($topicName, "{$topicName}.group_id = {$groupName}.group_id", "{$topicName}.topic_id")->where("{$groupName}.search = ?", 1)->where("{$groupName}.is_subgroup = ?", 0)->where("{$topicName}.creation_date > ?", $newdate)->group("{$groupName}.group_id")->order("COUNT('topic_id') DESC")->limit($count);
     $this->view->activegroups = $groups = $groupTable->fetchAll($select);
     $this->view->limit = $count;
     if (count($groups) <= 0) {
         //return $this->setNoRender();
     }
     //group directory
     $request = Zend_Controller_Front::getInstance()->getRequest();
     // clear title of widget
     if ($request->isPost()) {
         $this->getElement()->setTitle('');
         $element = $this->getElement();
     }
     $table = Engine_Api::_()->getItemTable('group');
     $select = $table->select()->where('search = ?', 1)->where('is_subgroup = ?', 0)->order('title ASC');
     $this->view->directory = $paginator = Zend_Paginator::factory($select);
     // Set item count per page and current page number
     $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 12));
     $paginator->setCurrentPageNumber($this->_getParam('page', 1));
     if (count($paginator) <= 0) {
         //return $this->setNoRender();
     }
 }